Part Number Hot Search : 
XF10B1Q1 C143Z CDLL942 L7808A TGA4832 AX519BMJ 1A470 CSNE33
Product Description
Full Text Search
 

To Download C8051F536-C-IT Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  8/4/2 kb isp flash mcu family c8051f52x/f53x rev. 1.4 4/12 copyright ? 2012 by silicon laboratories c8051f52x/f53x analog peripherals - 12-bit adc ? programmable throughput up to 200 ksps ? up to 6/16 external inputs ? data dependent windowed interrupt generator ? built-in temperature sensor - comparator ? programmable hysteresis and response time ? configurable as wake-up or reset source ? low current - por/brownout detector - voltage reference?1.5 and 2.2 v ? (programmable) on-chip debug - on-chip debug circuitry facilitates full-speed, non- intrusive in-system debug (no emulator required) - provides breakpoints, single stepping - inspect/modify memory and registers - complete development kit supply voltage 2.0 to 5.25 v - built-in ldo regulator high-speed 8051 c core - pipelined instruction architecture; executes 70% of instructions in 1 or 2 system clocks - up to 25 mips throughput with ? 25 mhz system clock - expanded interrupt handler memory - 8/4/2 kb flash; in-system byte programmable in 512 byte sectors - 256 bytes internal data ram digital peripherals - 16/6 port i/o; push-pull or open-drain, 5 v tolerant - hardware spi?, and uart serial port - lin 2.1 controller (master and slave capable); no crystal required - three general purpose 16-bit counter/timers - programmable 16-bit counter/timer array with three capture/compare modules, wdt clock sources - internal oscilla tors: 24.5 mhz 0.5% accuracy sup- ports uart and lin-master operation - external oscillator: crystal, rc, c, or clock ? (1 or 2 pin modes) - can switch between cl ock sources on-the-fly packages - 10-pin dfn (3 x 3 mm) - 20-pin qfn (4 x 4 mm) - 20-pin tssop automotive qualified - temperature range: ?40 to +125 c - compliant to aec-q100 analog peripherals 12-bit 200 ksps adc 8/4/2 kb isp flash 256 b sram por debug circuitry flexible interrupts 8051 cpu (25 mips) temp sensor digital i/o 24.5 mhz high precision (0.5%) internal oscillator high-speed controller core a m u x crossbar voltage comparator + - wdt uart pca timer 0 timer 1 timer 2 port 0 spi port 1 vreg vref lin
c8051f52x/f53x 2 rev. 1.4
rev. 1.4 3 c8051f52x/f53x table of contents 1. system overview ........ .................................................................................. ........... 13 1.1. ordering information.. ............................................................................. ........... 14 1.2. cip-51? microcontroller ...... .................................................................. ........... 18 1.2.1. fully 8051 compat ible instruction set ... .......................................... ......... 18 1.2.2. improved throughput ................. .................................................. ............. 18 1.2.3. additional features ...... .................................................................. ........... 18 1.2.4. on-chip debug circ uitry ................................................................ ........... 18 1.3. on-chip memory ....... ............................................................................. ........... 20 1.4. operating modes ....... ............................................................................. ........... 21 1.5. 12-bit analog to digital conv erter .................... .............. ............... ........... ......... 22 1.6. programmable comparator ....... ............................................................. ........... 23 1.7. voltage regulator...... ............................................................................. ........... 23 1.8. serial port...... ......................................................................................... ........... 23 1.9. port input/output .... ................................................................................ ........... 24 2. electrical characteristics ......... .................................................................. ............. 25 2.1. absolute maximum ratings.. .................................................................. ........... 25 2.2. electrical characteri stics ................ ........................................................ ........... 26 3. pinout and package definitions ..... ............................................................. ........... 35 4. 12-bit adc (adc0) ........ ................................................................................ ........... 52 4.1. analog multiplexer ..... ............................................................................. ........... 52 4.2. temperature sensor.. ............................................................................. ........... 53 4.3. adc0 operation ........ ............................................................................. ........... 54 4.3.1. starting a conversion...... ............................................................... ........... 54 4.3.2. tracking modes............... ............................................................... ........... 54 4.3.3. timing ............... ............................................................................. ........... 55 4.3.4. burst mode................... .................................................................. ........... 57 4.3.5. output conversion code............... ................................................. ........... 59 4.3.6. settling time requirement s........................................................... ........... 60 4.4. selectable gain ...... ................................................................................ ........... 60 4.4.1. calculating the gain valu e.............. ............................................... ........... 61 4.4.2. setting the gain value .... ............................................................... ........... 62 4.5. programmable window detector ............... ............................................. ........... 69 4.5.1. window detector in si ngle-ended mode ........ ............................... ........... 71 5. voltage reference....... .................................................................................. ........... 72 6. voltage regulator (reg0) ........ .................................................................. ............. 74 7. comparator ....... ........................................................................................... ........... 76 8. cip-51 microcontroller.............. .................................................................. ............. 81 8.1. instruction set......... ................................................................................ ........... 82 8.1.1. instruction and cpu timing ....... .................................................. ............. 82 8.1.2. movx instruction and prog ram memory ........... ............................ ........... 83 8.2. register descriptions ............................................................................. ........... 86 8.3. power management modes......... ........................................................... ........... 89 8.3.1. idle mode .......... ............................................................................. ........... 90
c8051f52x/f53x 4 rev. 1.4 8.3.2. stop mode......... ............................................................................. ........... 90 8.3.3. suspend mode ...... ......................................................................... ........... 90 9. memory organization and sfrs... ............................................................... ........... 92 9.1. program memory....... ............................................................................. ........... 92 9.2. data memory .......... ................................................................................ ........... 93 9.3. general purpose registers .. .................................................................. ........... 93 9.4. bit addressable loca tions .................. .................................................. ............. 93 9.5. stack ............. .................................................................................. ............. 93 9.6. special function registers... .................................................................. ........... 93 10. interrupt handler......... ................................................................................ ........... 98 10.1. mcu interrupt sour ces and vectors........... .......................................... ........... 98 10.2. interrupt priorities . ................................................................................ ........... 98 10.3. interrupt latency...... ............................................................................. ........... 98 10.4. interrupt register descripti ons .............. ............................................... ......... 100 10.5. external interrupts ............ .................................................................. ........... 104 11. reset sources ........... .................................................................................. ......... 106 11.1. power-on reset ...... ............................................................................. ......... 107 11.2. power-fail reset / vd d monitors (vddmon0 and vd dmon1) ......... ......... 108 11.2.1. vdd monitor threshol ds and minimum vdd............ ................. ........... 108 11.3. external reset ................ ...................................................................... ......... 110 11.4. missing clock detector reset . ............................................................. ......... 110 11.5. comparator reset .............. .................................................................. ......... 110 11.6. pca watchdog timer reset ..... ........................................................... ......... 110 11.7. flash error reset .... ............................................................................. ......... 110 11.8. software reset ........ ............................................................................. ......... 111 12. flash memory.............. ................................................................................ ......... 113 12.1. programming the flash memo ry ............... .......................................... ......... 113 12.1.1. flash lock and key functi ons ............... .............. ............... .................. 113 12.1.2. flash erase procedure ..... ........................................................... ......... 114 12.1.3. flash write procedure ..... ............... ............................................. ......... 114 12.2. flash write and erase guidel ines .............. .......................................... ......... 115 12.2.1. v dd maintenance and the v dd monitor ........... ............................ ......... 115 12.2.2. pswe maintenance ............. ........................................................ ......... 115 12.2.3. system clock ...... ......................................................................... ......... 116 12.3. non-volatile data storage .. .................................................................. ......... 117 12.4. security options ...... ............................................................................. ......... 117 13. port input/output ...... .................................................................................. ......... 120 13.1. priority crossbar decoder .. .................................................................. ......... 122 13.2. port i/o initializatio n ................ ............................................................. ......... 126 13.3. general purpose port i/o ... .................................................................. ......... 128 14. oscillators ............... .................................................................................. ........... 135 14.1. programmable internal oscill ator ................... .............. ............... .................. 135 14.1.1. internal oscillator sus pend mode ............... ................................. ......... 136 14.2. external oscillator drive circuit........ .................................................. ........... 139 14.2.1. clocking timers directly through the external oscillator... .................. 139
rev. 1.4 5 c8051f52x/f53x 14.2.2. external crystal example. ............... ............................................. ......... 139 14.2.3. external rc example...... ............................................................. ......... 141 14.2.4. external capacitor exam ple............... .......................................... ......... 141 14.3. system clock selection...... .................................................................. ......... 143 15. uart0 ................. ......................................................................................... ......... 144 15.1. enhanced baud rate generati on............ ............................................. ......... 145 15.2. operational modes ............. .................................................................. ......... 146 15.2.1. 8-bit uart ........ ........................................................................... ......... 146 15.2.2. 9-bit uart ........ ........................................................................... ......... 147 15.3. multiprocessor communication s ................ .......................................... ......... 148 16. enhanced serial peripheral in terface (spi0) ......... ................................. ........... 151 16.1. signal descriptions.. ............................................................................. ......... 152 16.1.1. master out, slave in (m osi).............. .......................................... ......... 152 16.1.2. master in, slave out (m iso).............. .......................................... ......... 152 16.1.3. serial clock (sck ) ................................................................................ 152 16.1.4. slave select (nss) ....... ............................................................... ......... 152 16.2. spi0 master mode op eration .............. ................................................. ......... 153 16.3. spi0 slave m ode operation .................. ............................................... ......... 154 16.4. spi0 interrupt sources ....... .................................................................. ......... 155 16.5. serial clock timing.. ............................................................................. ......... 156 16.6. spi special function register s ............................................................ ......... 156 17. lin (c8051f520/0a/3/3a/6/6a and c8051f530/0a/3/3a/ 6/6a) ............ .............. 164 17.1. software interface with the lin peripheral .......... ................................. ......... 165 17.2. lin interface setup and oper ation....................................................... ......... 165 17.2.1. mode definition .. ............... ........................................................... ......... 165 17.2.2. baud rate options: man ual or autobaud ............... ............ .................. 165 17.2.3. baud rate calculations?manual mode ... ................................. ........... 165 17.2.4. baud rate calculations?automatic m ode ............... ................. ........... 168 17.3. lin master mode operation ... ............... ............................................... ......... 169 17.4. lin slave mode operation ...... ............................................................. ......... 170 17.5. sleep mode and wake-up ...... ............................................................. ......... 171 17.6. error detection and handling ... ............... ............................................. ......... 171 17.7. lin registers........... ............................................................................. ......... 172 17.7.1. lin direct access sfr registers definition ........... ............ .................. 172 17.7.2. lin indirect access sf r regis ters definition......... ............ .................. 174 18. timers ................... .................................................................................. .............. 18 2 18.1. timer 0 and timer 1 ... ............... ........................................................... ......... 182 18.1.1. mode 0: 13-bit counter/timer ............ .......................................... ......... 182 18.1.2. mode 1: 16-bit counter/timer ............ .......................................... ......... 184 18.1.3. mode 2: 8-bit counter/timer with auto-reload.... ............... .................. 184 18.1.4. mode 3: two 8-bit co unter/timers (timer 0 only)... ............................. 185 18.2. timer 2 .......... ....................................................................................... ......... 190 18.2.1. 16-bit timer with auto-rel oad................ .............. ............... .................. 190 18.2.2. 8-bit timers with auto -reload...................................................... ......... 191 18.2.3. external capture mode .... ............... ............................................. ......... 192
c8051f52x/f53x 6 rev. 1.4 19. programmable counter array (pca0)............. .......................................... ......... 195 19.1. pca counter/timer ............ .................................................................. ......... 196 19.2. capture/compare modules ..... ............................................................. ......... 197 19.2.1. edge-triggered capture m ode.............................. ............... .................. 198 19.2.2. software timer (compare) mode................ ................................. ......... 199 19.2.3. high speed output mode............................................................. ......... 200 19.2.4. frequency output mode ............... ............................................... ......... 201 19.2.5. 8-bit pulse width modulat or mode.............. ................................. ......... 202 19.2.6. 16-bit pulse width modul ator mode....... .............. ............... .................. 203 19.3. watchdog timer mode ... ...................................................................... ......... 203 19.3.1. watchdog timer o peration .................. ................................................. 204 19.3.2. watchdog timer usage ....... ........................................................ ......... 205 19.4. register descriptions for pc a.............................................................. ......... 206 20. device specific behavior ......... .................................................................. ......... 210 20.1. device identific ation .................. ........................................................... ......... 210 20.2. reset pin behavior............. .................................................................. ......... 211 20.3. reset time delay .... ............................................................................. ......... 211 20.4. vdd monitors and vdd ram p time ..... ............................................... ......... 211 20.5. vdd monitor (vddmon0) hig h threshold setting ........... ................. ........... 212 20.6. reset low time....... ............................................................................. ......... 212 20.7. internal oscillator suspen d mode .................. .............. ............... .................. 212 20.8. uart pins............ ................................................................................ ......... 213 20.9. lin ............... ......................................................................................... ......... 213 20.9.1. stop bit check .... ......................................................................... ......... 213 20.9.2. synch break and synch field length check............ ................. ........... 213 21. c2 interface ............. .................................................................................. ........... 214 21.1. c2 interface registers........ .................................................................. ......... 214 21.2. c2 pin sharing ........ ............................................................................. ......... 216 document change list............... ...................................................................... ......... 217 contact information.......... ................................................................................ ......... 220
rev. 1.4 7 c8051f52x/f53x list of figures figure 1.1. c8051f53xa/f53x-c block diagram ........ ................................. ........... 16 figure 1.2. c8051f52xa/f52x-c block diagram ........ ................................. ........... 16 figure 1.3. c8051f53x block diagram (silicon revision a) ... ............ ........... ......... 17 figure 1.4. c8051f52x block diagram (silicon revision a) ... ............ ........... ......... 17 figure 1.5. development/in-syst em debug diagram .... ............................... ........... 19 figure 1.6. memory map .. ................. ........................................................... ........... 20 figure 1.7. 12-bit adc block diagr am ................... .............. ............... ........... ......... 22 figure 1.8. comparator block di agram .............. .......................................... ........... 23 figure 1.9. port i/o fu nctional block diagram ... .......................................... ........... 24 figure 3.1. dfn-10 pi nout diagram (top view) ............... ............................ ........... 35 figure 3.2. dfn-10 pack age diagram ............... .......................................... ........... 38 figure 3.3. dfn-10 landi ng diagram ................ .......................................... ........... 39 figure 3.4. tssop-20 pinout di agram (top view) ..... ................................. ........... 40 figure 3.5. tssop-20 package di agram ............ .......................................... ......... 43 figure 3.6. tssop-20 landing diagr am .............. .......................................... ......... 44 figure 3.7. qfn-20 pinout diagr am (top view) ......... ................................. ........... 45 figure 3.8. qfn-20 package diagr am* .............. .......................................... ........... 48 figure 3.9. qfn-20 landi ng diagram* ............... .......................................... ........... 50 figure 4.1. adc0 functional blo ck diagram ............. ................................. ............. 52 figure 4.2. typical temperatur e sensor transfer function .... ............ ........... ......... 53 figure 4.3. adc0 tracking modes ............................................................... ........... 55 figure 4.4. 12-bit adc tracking mode example ......... ................................. ........... 56 figure 4.5. 12-bit adc burst mode example with repeat count set to 4 .............. 58 figure 4.6. adc0 equivalent i nput circuits ............ .............. ............... ........... ......... 60 figure 4.7. adc window compare example: ? right-justified single-ended da ta ................. ............................ ........... 71 figure 4.8. adc window compare example: ? left-justified single-ended da ta ............ ................................. ............. 71 figure 5.1. voltage reference functional block diagram ....... ............ ........... ......... 72 figure 6.1. external capacit ors for voltage regulator input/o utput .......... ............. 74 figure 7.1. comparator functi onal block diagram ..... ................................. ........... 76 figure 7.2. comparator hysteresis plot ................. .............. ............... ........... ......... 77 figure 8.1. cip-51 block diagram ................... ............................................. ........... 81 figure 9.1. memory map .. ................. ........................................................... ........... 92 figure 11.1. reset sources ........ .................................................................. ......... 106 figure 11.2. power-on and v dd monitor reset timing ............... ................ ......... 107 figure 12.1. flash program memo ry map .......... .......................................... ......... 117 figure 13.1. port i/o f unctional block diagram ............... ............................ ......... 120 figure 13.2. port i/o cell block diagram ........ ............................................. ......... 121 figure 13.3. crossbar priority decoder with no pins skipped ? (tssop 20 and qfn 20) ........................ ................................. ......... 122 figure 13.4. crossbar priority de coder with crystal pins skipped ? (tssop 20 and qfn 20) ........................ ................................. ......... 123
c8051f52x/f53x 8 rev. 1.4 figure 13.5. crossbar priori ty decoder with no pins sk ipped (dfn 10) ... ........... 124 figure 13.6. crossbar priori ty decoder with some pins skipped (dfn 10) ......... 125 figure 14.1. oscillator diagram .. .................................................................. ......... 135 figure 14.2. 32 khz external cr ystal example .......... ................................. ........... 140 figure 15.1. uart0 block diagram ............................................................. ......... 144 figure 15.2. uart0 baud rate logic ................ .......................................... ......... 145 figure 15.3. uart interconnect di agram ............ ................................................. 146 figure 15.4. 8-bit uart timing diagram ........... .......................................... ......... 146 figure 15.5. 9-bit uart timing diagram ........... .......................................... ......... 147 figure 15.6. uart multi-proc essor mode interconne ct diagram ......... ................ 148 figure 16.1. spi block di agram ............... .................................................. ........... 151 figure 16.2. multiple-master mode connection diagram ........ ............ .................. 154 figure 16.3. 3-wire single master and slav e mode connection diagr am ............ 154 figure 16.4. 4-wire single master and slav e mode connection diagr am ............ 154 figure 16.5. data/clock timing relationship ..... .......................................... ......... 156 figure 16.6. spi master timing (ckpha = 0) .... .......................................... ......... 161 figure 16.7. spi master timing (ckpha = 1) .... .......................................... ......... 161 figure 16.8. spi slave timing (ckpha = 0) ...... .......................................... ......... 162 figure 16.9. spi slave timing (ckpha = 1) ...... .......................................... ......... 162 figure 17.1. lin block diagram . .................................................................. ......... 164 figure 18.1. t0 mode 0 bl ock diagram .............. .......................................... ......... 183 figure 18.2. t0 mode 2 bl ock diagram .............. .......................................... ......... 184 figure 18.3. t0 mode 3 bl ock diagram .............. .......................................... ......... 185 figure 18.4. timer 2 16-bit mode block diagram ....... ................................. ......... 190 figure 18.5. timer 2 8-bit mode block diagram ....... ................................. ........... 191 figure 18.6. timer 2 capture mode block diagram ................ ............ .................. 192 figure 19.1. pca block diagram ... ............................................................... ......... 195 figure 19.2. pca counter/timer block diagram ......... ................................. ......... 196 figure 19.3. pca interrupt block diagram ................ ................................. ........... 197 figure 19.4. pca capture mode dia gram ............ ................................................. 198 figure 19.5. pca software time r mode diagram ....... ................................. ......... 199 figure 19.6. pca high-speed out put mode diagram ... ............................... ......... 200 figure 19.7. pca frequen cy output mode .......... ................................................. 201 figure 19.8. pca 8-bit pwm mode diagram ......... .............. ............... .................. 202 figure 19.9. pca 16-bit pwm mode ............... ............................................. ......... 203 figure 19.10. pca module 2 wi th watchdog timer enabled .... ................. ........... 204 figure 20.1. device package?tsso p 20 ........... ................................................. 210 figure 20.2. device package?qfn 20 ............... ................................................. 210 figure 20.3. device package?dfn 10 ............... ................................................. 211 figure 21.1. typical c2 pin shar ing ................ ............................................. ......... 216
rev. 1.4 9 c8051f52x/f53x list of tables table 1.1. product selecti on guide (recommended for new designs) ....... ........... 14 table 1.2. product selecti on guide (not recommended for new designs) ........... 15 table 1.3. operati ng modes summary .......... ............................................... ........... 21 table 2.1. absolute maximum rati ngs ................... .............. ............... ........... ......... 25 table 2.2. global dc electrical characteristics ........... ................................. ........... 26 table 2.3. adc0 elec trical characteristics .... ............................................... ........... 28 table 2.4. temperature sensor electrical characteri stics ........ ................. ............. 29 table 2.5. voltage reference elec trical characteristi cs .............. ................ ........... 29 table 2.6. voltage regula tor electrical s pecifications ................. ................ ........... 30 table 2.7. comparator electrical characteristics ... .............. ............... ........... ......... 31 table 2.8. reset electric al characteristics ...... ............................................. ........... 32 table 2.9. flash electrical char acteristics ...... ............................................. ........... 33 table 2.10. port i/o dc electrical characteristics ............ ............................ ........... 33 table 2.11. internal oscillator el ectrical characteristics ...... ............... ........... ......... 34 table 3.1. pin definitions for the c8051f52x and c8051f52x a (dfn 10) ............. 36 table 3.2. dfn-10 package diagram dimensions ........ ............................... ........... 38 table 3.3. dfn-10 landing diagram dimensions ....... ................................. ........... 39 table 3.4. pin definitions for the c8051f53x and c805153x a (tssop 20) .......... 40 table 3.5. tssop-20 pa ckage diagram dimensions .......... ............... ........... ......... 43 table 3.6. tssop-20 landing di agram dimensions .. ................................. ........... 44 table 3.7. pin definitions for the c8051f53x and c805153xa (qfn 20) ............... 46 table 3.8. qfn-20 package diagram dimensions .............. ............... ........... ......... 49 table 3.9. qfn-20 landing diagram dimensions .. .............. ............... ........... ......... 51 table 8.1. cip-51 instruction se t summary .............. ................................. ............. 83 table 9.1. special function regi ster (sfr) memory map ...... ............ ........... ......... 94 table 9.2. special functi on registers ................ .......................................... ........... 95 table 10.1. interrupt summ ary ................. .................................................. ............. 99 table 12.1. flash security summar y ................. .......................................... ......... 118 table 15.1. timer settings for standard baud rates ? using the internal osci llator ............ .......................................... ......... 150 table 16.1. spi slave timing para meters ......... .......................................... ......... 163 table 17.1. baud-rate ca lculation variable ranges ......... ................................... 166 table 17.2. manual baud rate pa rameters examples ........... ............ .................. 167 table 17.3. autobaud parameters ex amples .............. ................................. ......... 168 table 17.4. lin registers* (indire ctly addressable) .. ................................. ........... 174 table 19.1. pca timebase input op tions ............ ................................................. 196 table 19.2. pca0cpm register settings for pca captur e/compare modules .... 197 table 19.3. watchdog timer timeout intervals1 ......... ................................. ......... 205
c8051f52x/f53x 10 rev. 1.4 list of registers sfr definition 4.4. adc0 mx: adc0 channel select ................ ............... ........... ......... 64 sfr definition 4.5. adc0cf: adc0 configuration ....... ................................. ............. 65 sfr definition 4.6. adc0h: adc0 data word msb ...... ................................. ............. 66 sfr definition 4.7. adc0l: adc0 data word lsb .......................................... ........... 66 sfr definition 4.8. adc0cn : adc0 control .......... .......................................... ........... 67 sfr definition 4.9. adc0tk: adc0 tracking mode select ..... ............... ........... ......... 68 sfr definition 4.10. adc0gth: adc0 greater-than da ta high byte ...... ............ ...... 69 sfr definition 4.11. adc0gtl: adc0 greater-than da ta low byte ..... ........... ......... 69 sfr definition 4.12. adc0lth: adc0 less-than data high byte ................. ............. 70 sfr definition 4.13. adc0ltl: ad c0 less-than data low byte ...................... ......... 70 sfr definition 5.1. ref0cn : reference control .... .......................................... ........... 73 sfr definition 6.1. reg0cn : regulator control ..... .......................................... ........... 75 sfr definition 7.1. cpt0 cn: comparator0 control .............. ............................ ........... 78 sfr definition 7.2. cpt0 mx: comparator0 mux sele ction ................. .............. ......... 79 sfr definition 7.3. cpt0 md: comparator0 mode selection .. ............................ ......... 80 sfr definition 8.1. sp: sta ck pointer ................. ............................................... ........... 87 sfr definition 8.2. dpl: data po inter low byte ......... .............. ............... ........... ......... 87 sfr definition 8.3. dph: data pointer high byte . ............................................. ........... 87 sfr definition 8.4. psw: program status word ..... .......................................... ........... 88 sfr definition 8.5. acc: accumula tor ........ ........................................................ ......... 89 sfr definition 8.6. b: b r egister ............... ........................................................ ........... 89 sfr definition 8.7. pcon: power control ............ ............................................. ........... 91 sfr definition 10.1. ie: in terrupt enable .............. ............................................. ......... 100 sfr definition 10.2. ip: inte rrupt priority ............ ............................................... ......... 101 sfr definition 10.3. eie1 : extended interrupt enable 1 ......... ................................... 102 sfr definition 10.4. eip1 : extended interrupt priority 1 ....... ............................ ......... 103 sfr definition 10.5. it01cf: int0 /int1 configuration .. ................................. ........... 105 sfr definition 11.1. vddmon: vdd monitor control ...... ................................. ......... 109 sfr definition 11.2. rstsrc : reset source ......... .......................................... ......... 112 sfr definition 12.1. psctl: prog ram store r/w control ................................ ......... 119 sfr definition 12.2. flk ey: flash lock and key ..... ................................................. 119 sfr definition 13.1. xbr0: port i/o crossbar register 0 ..... ............................ ......... 127 sfr definition 13.2. xbr1: port i/o crossbar register 1 ..... ............................ ......... 128 sfr definition 13.3. p0: port0 ....... .................................................................. ........... 129 sfr definition 13.4. p0mdin: port 0 input mode ............ ................................. ........... 129 sfr definition 13.5. p0md out: port0 output mode ................................................. 130 sfr definition 13.6. p0skip: port0 skip .............. ............................................. ......... 130 sfr definition 13.7. p0mat: port0 match .............. .......................................... ......... 131 sfr definition 13.8. p0mask : port0 mask ............. .......................................... ......... 131 sfr definition 13.9. p1: port1 ....... .................................................................. ........... 132 sfr definition 13.10. p1mdin: port 1 input mode ............ ................................. ......... 132 sfr definition 13.11. p1md out: port1 output mode ................. ............ .................. 133 sfr definition 13.12. p1skip: port1 skip ............ ............................................. ......... 133
rev. 1.4 11 c8051f52x/f53x sfr definition 13.13. p0skip: port0 skip ............ ............................................. ......... 134 sfr definition 13.14. p1mat: port1 match ............ .......................................... ......... 134 sfr definition 13.15. p1ma sk: port1 mask ........... .......................................... ......... 134 sfr definition 14.1. oscicn: inte rnal oscillator control ......... ............... .................. 137 sfr definition 14.2. oscicl: intern al oscillator calibration .... ............... .................. 138 sfr definition 14.3. oscifin: in ternal fine oscillator calibration .......... .................. 138 sfr definition 14.4. oscx cn: external oscillator control ................. .............. ......... 142 sfr definition 14.5. clksel: clock select ............ .......................................... ......... 143 sfr definition 15.1. scon0: serial port 0 control ..... .............. ............... .................. 149 sfr definition 15.2. sbuf0: seri al (uart0) port data buffer . ............... .................. 150 sfr definition 16.1. spi0cfg: spi 0 configuration ....... ................................. ........... 157 sfr definition 16.2. spi0cn : spi0 control ............ .......................................... ......... 158 sfr definition 16.3. spi0ckr: spi 0 clock rate ........... ................................. ........... 159 sfr definition 16.4. spi0dat: spi0 data ........... ............................................. ......... 160 sfr definition 17.1. linad dr: indirect address r egister ........ ............... .................. 172 sfr definition 17.2. lindata : lin data register .. .......................................... ......... 172 sfr definition 17.3. lincf control mode regi ster .............. ............................ ......... 173 sfr definition 17.4. lin0dt1: lin0 data byte 1 ........ .............. ............... .................. 174 sfr definition 17.5. lin0dt2: lin0 data byte 2 ........ .............. ............... .................. 175 sfr definition 17.6. lin0dt3: lin0 data byte 3 ........ .............. ............... .................. 175 sfr definition 17.7. lin0dt4: lin0 data byte 4 ........ .............. ............... .................. 175 sfr definition 17.8. lin0dt5: lin0 data byte 5 ........ .............. ............... .................. 176 sfr definition 17.9. lin0dt6: lin0 data byte 6 ........ .............. ............... .................. 176 sfr definition 17.10. lin0dt 7: lin0 data byte 7 .. .......................................... ......... 176 sfr definition 17.11. lin0dt 8: lin0 data byte 8 .. .......................................... ......... 176 sfr definition 17.12. lin0ctrl: li n0 control register .......... ............... .................. 177 sfr definition 17.13. lin0 st: lin0 status register ........ ............................ ......... 178 sfr definition 17.14. lin0 err: lin0 error register ......... ................................... 179 sfr definition 17.15. lin0 size: lin0 message size register .................................. 180 sfr definition 17.16. lin0div: lin0 divider register ... ................................. ........... 180 sfr definition 17.17. lin0mu l: lin0 multiplier register ..... ............................ ......... 181 sfr definition 17.18. lin0id : lin0 id register ... ............................................. ......... 181 sfr definition 18.1. tcon: timer c ontrol .............. .......................................... ......... 186 sfr definition 18.2. tmod: timer m ode ................ .......................................... ......... 187 sfr definition 18.3. ckcon: clock control ........... .......................................... ......... 188 sfr definition 18.4. tl0: timer 0 low byte ......... ............................................. ......... 189 sfr definition 18.5. tl1: timer 1 low byte ......... ............................................. ......... 189 sfr definition 18.6. th0: timer 0 high byte .............. .............. ............... .................. 189 sfr definition 18.7. th1: timer 1 high byte .............. .............. ............... .................. 189 sfr definition 18.8. tmr2cn: timer 2 control ............. ................................. ........... 193 sfr definition 18.9. tmr2rll: ti mer 2 reload register low byte ............... ........... 194 sfr definition 18.10. tmr2 rlh: timer 2 reload register high byte . ..................... 194 sfr definition 18.11. tmr2l: timer 2 low byte .... .......................................... ......... 194 sfr definition 18.12. tmr2h timer 2 high byte ........... ................................. ........... 194 sfr definition 19.1. pca0cn : pca control ........... .......................................... ......... 206
c8051f52x/f53x 12 rev. 1.4 sfr definition 19.2. pca0md: pca mo de ............. .......................................... ......... 207 sfr definition 19.3. pca0cpmn : pca capture/compare mode .. ................. ........... 208 sfr definition 19.4. pca 0l: pca counter/timer low byte ................. ..................... 209 sfr definition 19.5. pca0h: pca counter/timer high byte ....... ............ .................. 209 sfr definition 19.6. pca0cpln: pca capture module low byte . ................. ........... 209 sfr definition 19.7. pca0cphn: pca capture module high byte ................ ........... 209 c2 register definition 21.1. c2ad d: c2 address ....... .............. ............... .................. 214 c2 register definition 21.2. devi ceid: c2 device id .............. ............... .................. 214 c2 register definition 21.3. revi d: c2 revision id ............... ................................... 215 c2 register definition 21.4. fp ctl: c2 flash programming cont rol ............. ........... 215 c2 register definition 21.5. fp dat: c2 flash programming data ................. ........... 215
rev. 1.4 13 c8051f52x/f53x 1. system overview the c8051f52x/f52xa/f53x/f53xa family of devices are fully integrated, low power, mixed-signal system- on-a-chip mcus. highlighted features are listed below. refer to table 1.1 for specific product feature selection. ? high-speed pipelined 8051-compatible microcontroller core (up to 25 mips) ? in-system, full-speed, non-intrusive debug interface (on-chip) ? true 12-bit 200 ksps adc with analog multiplexer and up to 16 analog inputs ? precision programmable 24.5 mhz inte rnal oscillator that is within 0 .5% across the temperature range and for vdd voltages greater than or equal to the on-chip voltage regulator minimum output at the low setting. the oscillator is within + 1.0% for vdd voltages below th is minimum output setting. ? up to 7680 bytes of on-chip flash memory ? 256 bytes of on-chip ram ? enhanced uart, and spi serial interfaces implemented in hardware ? lin 2.1 peripheral (fully backwards compatible, master and slave modes) ? three general-purpose 16-bit timers ? programmable counter/timer array (pca) with three capture/compare modules and watchdog timer function ? on-chip power-on reset, v dd monitor, and temperature sensor ? on-chip voltage comparator ? up to 16 port i/o with on-chip power-on reset, v dd monitor, watchdog timer, and clock oscillator, the c8051f52x/f52xa/f53x/f53xa devices are truly standa lone system-on-a-chip solutions. the flash mem- ory is byte writable and can be reprogrammed in-circuit, providing non-volatile data storage, and also allowing field upgrades of the 8051 firmware. user software has complete control of all peripherals, and may individually shut down any or all peripherals for power savings. the on-chip silicon laboratories 2-wi re (c2) development in terface allows non-intr usive (uses no on-chip resources), full speed, in-circuit debugging using the production mcu installed in the final application. this debug logic supports inspection and modification of memory and registers, setting breakpoints, single stepping, run and halt commands. all analog and digita l peripherals are fully functional while debugging using c2. the two c2 interface pins can be shared with user functions, allowing in-system programming and debugging without occupying package pins. each device is specified for 2.0 to 5.25 v operation (supply voltage can be up to 5.25 v using on-chip reg- ulator) over the automotive temperature range (?40 to +125 c). the f52x/f52xa is available in the dfn10 (3 x 3 mm) package. the f53x/f53xa is available in the qfn20 (4 x 4 mm) or the tssop20 pack- age.
c8051f52x/f53x 14 rev. 1.4 1.1. ordering information the following features are common to all devices in this family: ? 25 mhz system clock and 25 mips throughput (peak) ? 256 bytes of internal ram ? enhanced spi peripheral ? enhanced uart peripheral ? three timers ? three programmable counter array channels ? internal 24.5 mhz oscillator ? internal voltage regulator ? 12-bit, 200 ksps adc ? internal voltage reference and temperature sensor ? one analog comparator  table 1.1 shows the features that diff erentiate the devices in this family. all devices in table 1.1 are also available in an automoti ve version. for the automotive version, the -i in the ordering part number is replaced with -a. for exampl e, the automotive version of the c8051f520-c-im is the c8051f520-c-am. the -am and -at devices receive full automotive qualit y production status, incl uding aec-q100 qualifica- tion (fault coverage report available upon request), registration with international material data system (imds) and part production approval process (ppap) documentation. ppap documentation is available at www.silabs.com with a registered nda and approved user account. the -am and -at devices enable high volume automotive oem applications with their enhanced testing and pr ocessing. please contact silicon labs sales for more information regarding -am and -at devices for your automotive project. table 1.1. product selection guide (recommended for new designs) ordering part number flash memory (kb) port i/os lin package ordering part number flash memory (kb) port i/os lin package c8051f520-c-im 8 6 ? dfn-10 c8051f534-c-im 4 16 ? qfn-20 c8051f521-c-im 8 6 ? dfn-10 c8051f536-c-im 2 16 ? qfn-20 c8051f523-c-im 4 6 ? dfn-10 c8051f537-c-im 2 16 ? qfn-20 c8051f524-c-im 4 6 ? dfn-10 c8051f530-c-it 8 16 ? tssop-20 c8051f526-c-im 2 6 ? dfn-10 c8051f531-c-it 8 16 ? tssop-20 c8051f527-c-im 2 6 ? dfn-10 c8051f533-c-it 4 16 ? tssop-20 c8051f530-c-im 8 16 ? qfn-20 c8051f534-c-it 4 16 ? tssop-20 c8051f531-c-im 8 16 ? qfn-20 C8051F536-C-IT 2 16 ? tssop-20 c8051f533-c-im 4 16 ? qfn-20 c8051f537-c-it 2 16 ? tssop-20
rev. 1.4 15 c8051f52x/f53x the part numbers in table 1.2 are not recommended fo r new designs. instead, select the corresponding part number from table 1.1 (silicon re vision c) for your design. in table 1.2, the part numb ers in the format similar to c8051f520 -im are silicon revision a devices. the part numbers in the format similar to c8051f520a-im are silicon revision b devices. table 1.2. product selection guide (not recommended for new designs) ordering part number flash memory (kb) port i/os lin package ordering part number flash memory (kb) port i/os lin package c8051f520-im c8051f520a-im 86 ? dfn-10 c8051f534-im c8051f534a-im 416 ?qfn-20 c8051f521-im c8051f521a-im 8 6 ? dfn-10 c8051f536-im c8051f536a-im 216 ? qfn-20 c8051f523-im c8051f523a-im 46 ? dfn-10 c8051f537-im c8051f537a-im 216 ?qfn-20 c8051f524-im c8051f524a-im 4 6 ? dfn-10 c8051f530-it c8051f530a-it 816 ? tssop-20 c8051f526-im c8051f526a-im 26 ? dfn-10 c8051f531-it c8051f531a-it 8 16 ? tssop-20 c8051f527-im c8051f527a-im 2 6 ? dfn-10 c8051f533-it c8051f533a-it 416 ? tssop-20 c8051f530-im c8051f530a-im 816 ? qfn-20 c8051f534-it c8051f534a-it 4 16 ? tssop-20 c8051f531-im c8051f531a-im 8 16 ? qfn-20 c8051f536-it c8051f536a-it 216 ? tssop-20 c8051f533-im c8051f533a-im 416 ? qfn-20 c8051f537-it c8051f537a-it 2 16 ? tssop-20
c8051f52x/f53x 16 rev. 1.4 figure 1.1. c8051f53xa/f53x-c block diagram figure 1.2. c8051f52xa/f52x-c block diagram digital peripherals uart0 timers 0, 1, 2, 3 pca/ wdt lin 2.1 priority crossbar decoder p0.0/vref p0.1 p0.2 p0.3 p0.4/tx p0.5/rx p0.6/c2d p0.7/xtal1 crossbar control port i/o configuration sfr bus p1.0/xtal2 p1.1 p1.2/cnvstr p1.3 p1.4 p1.5 spi debug / programming hardware power on reset reset c2d c2ck/rst p1.6 p1.7 analog peripherals comparator + - 12-bit 200ksps adc a m u x temp sensor vref vdd vdd vref gnd cp0, cp0a voltage reference vref system clock setup external oscillator internal oscillator xtal1 cip-51 8051 controller core up to 8k byte flash program memory 256 byte sram port 0 drivers port 1 drivers voltage regulator (ldo) gnd vregin vdd xtal2 vregin digital peripherals uart0 timers 0, 1, 2, 3 pca/ wdt lin 2.1 priority crossbar decoder crossbar control port i/o configuration sfr bus spi debug / programming hardware power on reset reset c2d c2ck/rst analog peripherals comparator + - 12-bit 200ksps adc a m u x temp sensor vref vdd vdd vref gnd cp0, cp0a voltage reference vref system clock setup external oscillator internal oscillator xtal1 cip-51 8051 controller core up to 8k byte flash program memory 256 byte sram voltage regulator (ldo) gnd vregin vdd xtal2 vregin p0.0/vref p0.1/c2d p0.2/xtal1 p0.3/xtal2 p0.4/tx p0.5/rx/ cnvstr port 0 drivers
rev. 1.4 17 c8051f52x/f53x figure 1.3. c8051f53x block diagram (silicon revision a) figure 1.4. c8051f52x block diagram (silicon revision a) digital peripherals uart0 timers 0, 1, 2, 3 pca/ wdt lin 2.1 priority crossbar decoder p0.0/vref p0.1 p0.2 p0.3/tx p0.4/rx p0.5 p0.6/c2d p0.7/xtal1 crossbar control port i/o configuration sfr bus p1.0/xtal2 p1.1 p1.2/cnvstr p1.3 p1.4 p1.5 spi debug / programming hardware power on reset reset c2d c2ck/rst p1.6 p1.7 analog peripherals comparator + - 12-bit 200ksps adc a m u x temp sensor vref vdd vdd vref gnd cp0, cp0a voltage reference vref system clock setup external oscillator internal oscillator xtal1 cip-51 8051 controller core up to 8k byte flash program memory 256 byte sram port 0 drivers port 1 drivers voltage regulator (ldo) gnd vregin vdd xtal2 vregin digital peripherals uart0 timers 0, 1, 2, 3 pca/ wdt lin 2.1 priority crossbar decoder crossbar control port i/o configuration sfr bus spi debug / programming hardware power on reset reset c2d c2ck/rst analog peripherals comparator + - 12-bit 200ksps adc a m u x temp sensor vref vdd vdd vref gnd cp0, cp0a voltage reference vref system clock setup external oscillator internal oscillator xtal1 cip-51 8051 controller core up to 8k byte flash program memory 256 byte sram voltage regulator (ldo) gnd vregin vdd xtal2 vregin p0.0/vref p0.1/c2d p0.2/xtal1 p0.3/xtal2/tx p0.4/rx p0.5/cnvstr port 0 drivers
c8051f52x/f53x 18 rev. 1.4 1.2. cip-51? microcontroller 1.2.1. fully 8051 compatible instruction set the c8051f52x/f52xa/f53x/f 53xa devices use silicon laboratories ? proprietary cip- 51 microcontroller core. the cip-51 is fully compatib le with the mcs-51? instruction set. standard 803x/805x assemblers and compilers can be used to develop software. the c8 051f52x/f52xa/f53x/f53xa family has a superset of all the peripherals included with a standard 8052. 1.2.2. improved throughput the cip-51 employs a pipelined architecture that grea tly increases its instruction throughput over the stan- dard 8051 architecture. in a standar d 8051, all instructions except for mul and div take 12 or 24 system clock cycles to execute, and usua lly have a maximum system clock of 12 -to-24 mhz. by contrast, the cip- 51 core executes 70% of its instructions in one or tw o system clock cycles, with no instructions taking more than eight system clock cycles. with the cip-51's system clock runn ing at 25 mhz, it has a peak thro ughput of 25 mips. the cip-51 has a total of 109 instructions. the table below shows the tota l number of instructions th at require each execution time. 1.2.3. additional features the c8051f52x/f52xa/f53x/f53xa family includes several key enhancements to the cip-51 core and peripherals to improve performance and ease of use in end applications. an extended interrupt handler allows the numerous analog and digital peripherals to operate indepen- dently of the controller core and interrupt the controlle r only when necessary. by requiring less intervention from the microcontroller core, an interrupt-driven syste m is more efficient and allows for easier implemen- tation of multi-tasking, real-time systems. eight reset sources are available: power-on reset circuitry (por), an on-chip v dd monitor, a watchdog timer, a missing clock detector, a voltage level detect ion from comparator, a forced software reset, an external reset pin, and an illegal fl ash access protection circuit. each reset sour ce except for the por, reset input pin, or flash error may be disabled by the user in software. the wdt may be permanently enabled in software after a power -on reset during mcu initialization. the internal oscillator is factory ca librated to 24.5 mhz 0.5% across th e entire operati ng temperature and voltage range. an external oscillator drive circuit is also included, allowing an external crystal, ceramic res- onator, capacitor, rc, or cmos clock source to generate the system clock. 1.2.4. on-chip debug circuitry the c8051f52x/f52xa/f53x/f53xa devi ces include on-chip silicon labor atories 2-wire (c2) debug cir- cuitry that provides non-intrusive, full speed , in-circuit debugging of the production part installed in the end application. silicon laboratories? debugging system supports in spection and modification of memory and registers, breakpoints, and single stepping. no additional target ram, program memory, timers, or communications channels are required. all the digital and analog peri pherals are functional and work correctly while debug- ging. all the peripherals (except for the adc) are sta lled when the mcu is halted, during single stepping, or at a breakpoint in order to keep them synchronized. the c8051f530dk development kit provides all the har dware and software necessary to develop applica- tion code and perform in-circuit debugging wit h the c8051f52x/f52xa/f53x/f53xa mcus. the kit clocks to execute 1 2 2/3 3 3/4 4 4/5 5 8 number of instructions265051473121
rev. 1.4 19 c8051f52x/f53x includes software with a developer's studio and de bugger, a usb debug adapter, a target application board with the associated mcu installed, and the required cables and wall-mount power supply. the development kit requires a computer with windows installed. as shown in figure 1.5, the pc is connected to the usb debug adapter. a six-inch ribbon cable conn ects the usb debug adapte r to the user's applica- tion board, picking up the two c2 pins and gnd. the silicon laboratories ide interface is a vastly superior developi ng and debugging co nfiguration, com- pared to standard mcu emulators that use on-board "i ce chips" and require th e mcu in the application board to be socketed. silicon labor atories? debug paradigm increases ease of use and pr eserves the per- formance of the precision analog peripherals. figure 1.5. development/in-system debug diagram p5 p1 p1.4_a p1.4_b u3 u1 u2 silicon laboratories c8051f530a tb pwr d1 d2 t1 t2 j4 p1.7_b j3 p1.6_b j5 p0.0_b debug_b hdr1 reset_b debug_a hdr2 reset_a hdr3 ?b? side ?a? side j13 j14 j8 j6 hdr4 pc usb cable usb debug adapter ac/dc adapter target board silicon laboratories usb debug adapter run stop power
c8051f52x/f53x 20 rev. 1.4 1.3. on-chip memory the cip-51 has a standard 8051 program and data addr ess configuration. it in cludes 256 bytes of data ram, with the upper 128 bytes dual-mapped. indirect addressing accesses the upper 128 bytes of general purpose ram, and direct addressing accesses the 128 byte sfr addre ss space. the lower 128 bytes of ram are accessible via direct and indirect addressing. the first 32 bytes are addressable as four banks of general purpose registers, and the next 16 byte s can be byte addressable or bit addressable. program memory consists of 7680 bytes (?f520/0a/ 1/1a and ?f530/0a/1/1a), 4 kb (?f523/3a/4/4a and c8051f53x/53xa), or 2 kb (?f526/6a/7/7a and ?f536/6a/7 /7a) of flash. this memory is byte writable and erased in 512-byte sectors, and requires no special off-chip programming voltage. figure 1.6. memory map program/data memory (flash) 8 kb flash (in-system programmable in 512 byte sectors) 0x0000 reserved 'f520/0a/1/1a and 'f530/0a/1/1a 0x0000 'f523/3a/4/4a and 'f533/3a/4/4a 4 kb flash (in-system programmable in 512 byte sectors) reserved 'f526/6a/7/7a and 'f536/6a/7/7a 0x0000 2 kb flash (in-system programmable in 512 byte sectors) reserved (direct and indirect addressing) 0x00 0x7f upper 128 ram (indirect addressing only) 0x80 0xff special function register's (direct addressing only) data memory (ram) general purpose registers 0x1f 0x20 0x2f bit addressable lower 128 ram (direct and indirect addressing) 0x30 internal data address space 0x1e00 0x1dff 0x1000 0x0fff 0x0800 0x07ff
rev. 1.4 21 c8051f52x/f53x 1.4. operating modes the c8051f52x/f52xa/f53x/f53xa devices have four op erating modes: active (normal), idle, suspend, and stop. active mode occurs durin g normal operation when the oscillator and peripherals are active. idle mode halts the cpu while leaving the peripherals and internal clocks active. in suspend and stop mode, the cpu is halted, all interr upts and timers are inactive , and the internal oscillato r is stopped. the various operating modes are described in table 1.3 below: see section ?8.3. power management modes? on page 89 for idle and stop mode details. see section ?14.1.1. internal osc illator suspend mode? on page 136 fo r more informatio n on suspend mode. table 1.3. operating modes summary properties power consumption how entered? how exited? active ? sysclk active ? cpu active (accessing flash) ? peripherals active or inactive depending on user settings full ? ? idle ? sysclk active ? cpu inactive (not accessing flash) ? peripherals active or inactive depending on user settings less than full idle (pcon.0) any enabled interrupt or device reset suspend ? internal oscillator inactive ? if sysclk is derived from the internal oscillator, the peripherals and the cip-51 will be stopped low suspend (oscicn.5) port 0 event match port 1 event match comparator 0 enabled and output is logic 0 stop ? sysclk inactive ? cpu inactive (not accessing flash) ? digital peripherals inactive; analog peripherals active or inactive depending on user settings very low stop (pcon.1) device reset
c8051f52x/f53x 22 rev. 1.4 1.5. 12-bit analog to digital converter the c8051f52x/f52xa/f53x/f53xa devices include an on-chip 12-bit sar adc with a maximum through- put of 200 ksps. the adc system includes a configurab le analog multiplexer that selects the positive adc input, which is measured with respec t to gnd. ports 0 and 1 are available as adc inputs; additionally, the adc includes an innovative programmable gain stag e which allows the adc to sample inputs sources greater than the vref voltage. the on-chip temper ature sensor output and the core supply voltage (v dd ) are also available as adc inputs. user firmware may sh ut down the adc or use it in burst mode to save power. conversions can be initiated in four ways: a software command, an overflow of timer 1, an overflow of timer 2, or an external convert start signal. this flex ibility allows the start of c onversion to be triggered by software events, a periodic signal (timer overflows) , or external hw signals. conversion completions are indicated by a status bit and an interrupt (if enabled) and occur after 1, 4, 8, or 16 samples have been accumulated by a hardware accumulator. the resulting 12 -bit to 16-bit data word is latched into the adc data sfrs upon completion of a co nversion. when the system clock is slow, burst mode allows adc0 to automatically wake from a low power shutdown state, acquire and accumulate samples, then re-enter the low power shutdown state without cpu intervention. window compare registers for the adc data can be conf igured to interrupt the co ntroller when adc data is either within or outside of a specified range. the adc can monitor a key voltage continuously in back- ground mode, but not interrupt the controller unless the converted data is within/outside the specified range. figure 1.7. 12-bit adc block diagram 12-bit sar adc timer 2 overflow configuration, control, and data registers cnvstr rising edge start conversion ad0busy (w) 16 window compare logic window compare interrupt adc data registers end of conversion interrupt 19-to-1 amux p1.0* p1.7* analog multiplexer vdd temp sensor p0.0 p0.7* burst mode logic accumulator gnd * available on ?f53x/ ?f53xa devices p0.6* timer 1 overflow selectable gain
rev. 1.4 23 c8051f52x/f53x 1.6. programmable comparator c8051f52x/f52xa/f53x/f53xa devices include a softwa re-configurable voltage comparator with an input multiplexer. the comparator offers programmable res ponse time and hysteresis and an output that is optionally available at the port pins: a synchronous ?latched? output (cp0). the comparator interrupt may be generated on rising, falling, or both edges. when in idle or suspend mode, these interrupts may be used as a ?wake-up? source for the processor. the comparator may also be configured as a reset source. a block diagram of the comparat or is shown in figure 1.8. figure 1.8. comparator block diagram 1.7. voltage regulator c8051f52x/f52xa/f53x/f53xa devices include an on-chip low dropout voltage regulator (reg0). the input to reg0 at the v regin pin can be as high as 5.25 v. the output can be selected by software to 2.1 or 2.6 v. when enabled, the output of reg0 powers the device and drives the v dd pin. the voltage regulator can be used to power external devices connected to v dd . 1.8. serial port the c8051f52x/f52xa/f53x/f53xa family includes a full-duplex uart with enhanced baud rate configu- ration, and an enhanced spi interfac e. each of the serial buses is fully implemented in hardware and makes extensive use of the cip-51's interrupts, thus requiring very little cpu intervention. vdd reset decision tree + - q q set clr d q q set clr d (synchronizer) gnd cp0 (synchronous output) cp0a (asynchronous output) interrupt logic multiplexer port i/o pins
c8051f52x/f53x 24 rev. 1.4 1.9. port input/output c8051f52x/f52xa/f53x/f53xa devices include up to 16 i/o pins. port pins are organized as two byte- wide ports. the port pins behave like typical 8051 po rts with a few enhancements. each port pin can be configured as a digital or analog i/o pin. pins selected as digital i/o can be configured for push-pull or open-drain operation. the ?weak pullups? that are fixe d on typical 8051 devices may be globally disabled to save power. the digital crossbar allows mapping of internal digital system resources to port i/o pins. on-chip coun- ter/timers, serial buses, hardware interrupts, and othe r digital signals can be configured to appear on the port pins using the crossbar control registers. this allows the user to select the exact mix of general-pur- pose port i/o, digital, and analog resources needed for the application. figure 1.9. port i/o functional block diagram xbr0, xbr1, pnskip registers digital crossbar priority decoder 2 p0 i/o cells p0.0 p0.7 8 p0mask, p0match p1mask, p1match registers uart (internal digital signals) highest priority lowest priority sysclk t0, t1 2 7 pca cp0 outputs spi 4 p1 i/o cells p1.0* p1.7* 8 (port latches) p0 (p0.0-p0.7) (p1.0-p1.7*) 8 p1 8 pnmdout, pnmdin registers lin 2 2 *available in 'f53x/'f53xa devices
rev. 1.4 25 c8051f52x/f53x 2. electrical characteristics 2.1. absolute maximum ratings table 2.1. absolute maximum ratings parameter conditions min typ max units ambient temperature under bias ?55 ? 135 c storage temperature ?65 ? 150 c voltage on v regin with respect to gnd ?0.3 ? 5.5 v voltage on v dd with respect to gnd ?0.3 ? 2.8 v voltage on xtal1 with respect to gnd ?0.3 ? v regin + 0.3 v voltage on xtal2 with respect to gnd ?0.3 ? v regin + 0.3 v voltage on any port i/o pin or rst with respect to gnd ?0.3 ? v regin + 0.3 v maximum output current sunk by any port pin ? ? 100 ma maximum output current sourced by any port pin ? ? 100 ma maximum total current through v regin , and gnd ? ? 500 ma note: stresses above those listed under ?absolute maximum ratings? may cause permanent damage to the device. this is a stress rating only and functional operation of t he devices at those or any other conditions above those indicated in the operation listings of this specification is not implied. exposure to maximum rating conditions for extended periods may affect device reliability.
c8051f52x/f53x 26 rev. 1.4 2.2. electrical characteristics table 2.2. global dc electrical characteristics ?40 to +125 c, 25 mhz system clock unless otherwis e specified. typical values are given at 25 c parameter conditions min typ max units supply input voltage (v regin ) 1 output current < 1 ma c8051f52x/53x c8051f52xa/53xa c8051f52x-c/53x-c 2.7 1.8 1 2.0 1 ? ? ? 5.25 5.25 5.25 v v v digital supply voltage (v dd ) c8051f52x/53x c8051f52xa/53xa c8051f52x-c/53x-c 2.0 1.8 2.0 ? ? ? 2.7 2.7 2.75 v v v core supply ram data retention voltage ?1.5?v sysclk (system clock) 2 0?25mhz specified operating temperature range ?40 ? +125 c digital supply current?cpu active (normal mode, fetching instructions from flash) i dd 3,4 v dd = 2.1 v: clock = 32 khz clock = 200 khz clock = 1 mhz clock = 25 mhz v dd = 2.6 v: clock = 32 khz clock = 200 khz clock = 1 mhz clock = 25 mhz ? ? ? ? ? ? ? ? 13 60 0.28 5.1 22 105 0.5 7.3 ? ? ? 9 ? ? ? 13 a a ma ma a a ma ma i dd frequency sensitivity 3,5 t = 25 c: v dd = 2.1 v, f < 12 mhz v dd = 2.1 v, f > 12 mhz v dd = 2.6 v, f < 12 mhz v dd = 2.6 v, f > 12 mhz ? ? ? ? 0.276 0.140 0.424 0.184 ? ? ? ? ma/mhz ma/mhz ma/mhz ma/mhz notes: 1. for more information on v regin characteristics, see table 2.6 on page 30. 2. sysclk must be at least 32 khz to enable debugging. 3. based on device characterization data; not production tested. 4. does not include internal oscillator or internal regulator supply current. 5. i dd can be estimated for frequencies <= 12 mhz by mult iplying the frequency of interest by the frequency sensitivity number for that range. when using these numbers to estimate i dd > 12 mhz, the estimate should be the current at 25 mhz minus the difference in current indicated by the frequency sensitivity number. for example: v dd = 2.6 v; f= 20 mhz, i dd = 7.3 ma ? (25 mhz ? 20 mhz) x 0.184 ma/mhz = 6.38 ma. 6. idle i dd can be estimated for frequencies <= 1 mhz by multip lying the frequency of interest by the frequency sensitivity number for that range. when using these numbers to estimate i dd > 1 mhz, the estimate should be the current at 25 mhz minus the difference in current indicated by the frequency sensitivity number. for example: v dd = 2.6 v; f= 5 mhz, idle i dd = 3 ma ? (25 mhz? 5 mhz) x 118 a/mhz = 0.64 ma.
rev. 1.4 27 c8051f52x/f53x digital supply current?cpu inactive (idle mo de, not fetching instructions from flash) idle i dd 3,4 v dd = 2.1 v: clock = 32 khz clock = 200 khz clock = 1 mhz clock = 25 mhz v dd = 2.6 v: clock = 32 khz clock = 200 khz clock = 1 mhz clock = 25 mhz ? ? ? ? ? ? ? ? 8 22 0.09 2.2 9 30 0.13 3 ? ? ? 5 ? ? ? 6.5 a a ma ma a a ma ma idle i dd frequency sensitivity 3,6 t = 25 c: v dd = 2.1 v, f < 1 mhz v dd = 2.1 v, f > 1 mhz v dd = 2.6 v, f < 1 mhz v dd = 2.6 v, f > 1 mhz ? ? ? ? 90 90 118 118 ? ? ? ? a/mhz a/mhz a/mhz a/mhz digital supply current 3 (stop or suspend mode) oscillator not running, v dd monitor disabled. t = 25 c t = 60 c t = 125 c ? ? ? 2 3 50 ? ? ? a a a table 2.2. global dc electrical characteristics ?40 to +125 c, 25 mhz system clock unless otherwis e specified. typical values are given at 25 c parameter conditions min typ max units notes: 1. for more information on v regin characteristics, see table 2.6 on page 30. 2. sysclk must be at least 32 khz to enable debugging. 3. based on device characterization data; not production tested. 4. does not include internal oscillator or internal regulator supply current. 5. i dd can be estimated for frequencies <= 12 mhz by mult iplying the frequency of interest by the frequency sensitivity number for that range. when using these numbers to estimate i dd > 12 mhz, the estimate should be the current at 25 mhz minus the difference in current indicated by the frequency sensitivity number. for example: v dd = 2.6 v; f= 20 mhz, i dd = 7.3 ma ? (25 mhz ? 20 mhz) x 0.184 ma/mhz = 6.38 ma. 6. idle i dd can be estimated for frequencies <= 1 mhz by multip lying the frequency of interest by the frequency sensitivity number for that range. when using these numbers to estimate i dd > 1 mhz, the estimate should be the current at 25 mhz minus the difference in current indicated by the frequency sensitivity number. for example: v dd = 2.6 v; f= 5 mhz, idle i dd = 3 ma ? (25 mhz? 5 mhz) x 118 a/mhz = 0.64 ma.
c8051f52x/f53x 28 rev. 1.4 table 2.3. adc0 electrical characteristics v dd = 2.1 v, v ref = 1.5 v (refsl=0), ?40 to +125 c unless otherwise specified. parameter conditions min typ max units dc accuracy resolution 12 bits integral nonlinearity ? ? 3 lsb differential nonlinearity gu aranteed monotonic ? ? 1 lsb offset error 1 ?10 1 +10 lsb full scale error ?20 1 +20 lsb dynamic performance (10 khz sine-wave single-ended input, 0 to 1 db below full scale, 200 ksps) signal-to-noise plus distortion 60 66 ? db total harmonic distortion up to the 5 th harmonic ? 74 ? db spurious-free dynamic range ? 88 ? db conversion rate sar conversion clock ? ? 3 mhz burst mode oscillator ? ? 27 mhz conversion time in sar clocks 2 ? 13 ? clocks track/hold acquisition time 3,6 1? ? s throughput rate 4 ? ? 200 ksps analog inputs adc input voltage range 5 gain = 1.0 (default) gain = n 0 0 ? ? v ref v ref / n v absolute pin voltage wrt to gnd 0 ? v regin v sampling capacitance ? 24 ? pf input multiplexer impedance ? 1.5 ? k ? power specifications power supply current (from vdd) operating mode, 200 ksps ? 1050 1400 a burst mode (idle) ? 930 ? a power-on time ? 5 ? s power supply rejection ? 1 ? mv/v notes: 1. represents one standard deviation from the mean. of fset and full-scale error can be removed through calibration. 2. an additional 2 fclk cycles are required to start and complete a conversion. 3. additional tracking time may be required depending on the output impedance conn ected to the adc input. see section ?4.3.6. settling time requirements? on page 60. 4. an increase in tracking time will decrease the adc throughput. 5. see section ?4.4. selectable gain? on page 60 for more information about setting the gain. 6. additional tracking time might be needed ifvdd < 2.0 v; see section ?11.2.1. vdd monitor thresholds and minimum vdd? on page 108 for minimum v dd requirements.
rev. 1.4 29 c8051f52x/f53x table 2.4. temperature sensor electrical characteristics v dd = 2.1 v, v ref = 1.5 v (refsl=0), ?40 to +125 c unless otherwise specified. parameter conditions min typ max units linearity 1 ?0.1? c gain 1 ? 3.33 ? mv/c gain error 2 ? 100 ? v/c offset 1 temp = 0 c ? 890 ? mv offset error 2 te m p = 0 c ? 1 5 ? m v tracking time 12 ? ? s power supply current ? 17 ? a notes: 1. includes adc offset, gain, and linearity variations. 2. represents one standard deviation from the mean. table 2.5. voltage reference electrical characteristics v dd = 2.1 v; ?40 to +125 c unless otherwise specified. parameter conditions min typ max units internal reference (refbe = 1) output voltage i dd ? 1 ma; no load on vref pin and all other gpio pins. 25 c ambient (reflv = 0) 25 c ambient (reflv = 1), v dd = 2.6 v 1.45 2.15 1.5 2.2 1.55 2.25 v v ref short-circuit current ? 2.5 ? ma v ref temperature coefficient ? 33 ? ppm/c load regulation load = 0 to 200 a to gnd ? 10 ? ppm/a v ref turn-on time 1 4.7 f, 0.1 f bypass ? 21 ? ms v ref turn-on time 2 0.1 f bypass ? 230 ? s power supply rejection ? 2.1 ? mv/v external reference (refbe = 0) input voltage range 0 ? v dd v input current sample rate = 200 ksps; v ref = 1.5 v ? 2.4 ? a bias generators adc bias generator biase = 1 ? 22 ? a power consumption (internal) ? 35 ? a
c8051f52x/f53x 30 rev. 1.4 table 2.6. voltage regulator electrical specifications v dd = 2.1 or 2.6 v; ?40 to +125 c unless otherwise specified. parameter conditions min typ max units input voltage range (v regin ) c8051f52x/53x c8051f52xa/53xa v dd connected to v regin v dd not connected to v regin c8051f52x-c/53x-c v dd connected to v regin v dd not connected to v regin 2.7 1 1.8 2.2 2 2.0 2.2 2 ? ? ? ? ? 5.25 2.7 5.25 2.75 5.25 v dropout voltage (v do ) output current = 1-50 ma ? 10 ? mv/ma output voltage (v dd ) output current = 1 to 50 ma reg0md = 0 reg0md = 1 2.0 2.5 2.1 2.6 2.25 2.75 v bias current 2.1 v operation ? (reg0md = 0; t = 25 c) 2.6 v operation ? (reg0md = 1; t = 25 c) ? ? 1 1 5 5 a dropout indicator detection threshold ?75?mv output voltage temperature coefficient ? 0.25 ? mv/oc vreg settling time 50 ma load with v regin = 2.4 v and v dd load capacitor of 4.8 f ?250? s notes: 1. the minimum input voltage is 2.7 v or v dd + v do (max load), whichever is greater. 2. the minimum input voltage is 2.2 v or v dd + v do (max load), whichever is greater.
rev. 1.4 31 c8051f52x/f53x table 2.7. comparator electrical characteristics v regin = 2.7?5.25 v, ?40 to +125 c unless otherwise noted. ? all specifications apply to both comparat or0 and comparator1 unless otherwise noted. parameter conditions min typ max units response time: mode 0, vcm 1 = 1.5 v cp0+ ? cp0? = 100 mv ? 780 ? ns cp0+ ? cp0? = ?100 mv ? 980 ? ns response time: mode 1, vcm 1 = 1.5 v cp0+ ? cp0? = 100 mv ? 850 ? ns cp0+ ? cp0? = ?100 mv ? 1120 ? ns response time: mode 2, vcm 1 = 1.5 v cp0+ ? cp0? = 100 mv ? 870 ? ns cp0+ ? cp0? = ?100 mv ? 1310 ? ns response time: mode 3, vcm 1 = 1.5 v cp0+ ? cp0? = 100 mv ? 1980 ? ns cp0+ ? cp0? = ?100 mv ? 4770 ? ns common-mode rejection ratio ?3 9 mv/v positive hysteresis 1 cp0hyp1-0 = 00 ? 0.7 2 mv positive hysteresis 2 cp0hyp1-0 = 01 2 5 10 mv positive hysteresis 3 cp0hyp1-0 = 10 5 10 20 mv positive hysteresis 4 cp0hyp1-0 = 11 13 20 40 mv negative hysteresis 1 cp0hyn1-0 = 00 ? 0.7 2 mv negative hysteresis 2 cp0hyn1-0 = 01 2 5 10 mv negative hysteresis 3 cp0hyn1-0 = 10 5 10 20 mv negative hysteresis 4 cp0hyn1-0 = 11 13 20 40 mv inverting or non-inverting input voltage range 2 ?0.25 ? v dd + 0.25 v input capacitance 2 ?4 ? pf input bias current ? 0.5 ? na input offset voltage ?15 ? 15 mv input impedance ? 1.5 ? k ? power supply power supply rejection 2 ?0.2 4 mv/v power-up time ? 2.3 ? s supply current at dc mode 0 ? 6 30 a mode 1 ? 3 15 a mode 2 ? 2 7.5 a mode 3 ? 0.3 3.8 a notes: 1. vcm is the common-mode voltage on cp0+ and cp0?. 2. guaranteed by design and/or characterization.
c8051f52x/f53x 32 rev. 1.4 table 2.8. reset electrical characteristics ?40 to +125 c unless otherwise specified. parameter conditions min typ max units rst output low voltage i ol = 8.5 ma, v dd = 2.1 v ??0.8v rst input high voltage 0.7 x v regin ??v rst input low voltage ?? 0.3 x v regin v rst input pullup impedance v regin = 1.8 v v regin = 2.7 v v regin = 3.3 v v regin = 5 v ? ? ? ? 330 160 130 80 ? ? ? ? k? k? k? k? missing clock detector time out time from last system clock rising edge to reset initiation 100 350 650 s reset time delay (t pordelay ) 1 delay between release of any reset source and code execution at loca- tion 0x0000 ??350s minimum rst low time to generate a system reset 10 ? ? s v dd monitor (vddmon0) low threshold (v rst-low ) 1,2,3 c8051f52x/53x c8051f52xa/53xa c8051f52x-c/53x-c 1.8 1.65 1.65 1.9 1.75 1.75 2.0 1.8 1.8 v v v high threshold (v rst-high ) 3 c8051f52x/53x c8051f52xa/53xa c8051f52x-c/53x-c 2.1 2.25 2.25 2.2 2.3 2.3 2.3 2.4 2.45 v v v turn-on time ? 83 ? s supply current v dd = 2.1 v ? 1 2 a level-sensitive v dd monitor (vddmon1) 1 threshold (v rst1 ) 1,2,3 c8051f52x-c/53x-c 1.6 1.75 1.9 v supply current c8051f52x-c/53x-c ? 3 6 a notes: 1. refer to section ?20. device specific behavior? on page 210. 2. the por threshold (v rst ) is v rst-low or v rst1 , whichever is higher. 3. the v rst threshold for power fail / brownout is the higher of vddmon0 and vddmon1 thresholds, if both are enabled.
rev. 1.4 33 c8051f52x/f53x table 2.9. flash electrical characteristics v dd = 1.8 to 2.75 v; ?40 to +125 oc unless otherwise specified parameter conditions min typ max units flash size ?f520/0a/1/1a and ?f530/0a/1/1a ?f523/3a/4/4a and ?f533/3a/4/4a ?f526/6a/7/7a and ?f536/6a/7/7a 7680 4096 2048 ?? bytes endurance 2 v dd ? v rst-high 1 20 k 150 k ? erase/write erase cycle time 27 32 38 ms write cycle time 57 65 74 s v dd write/erase operations v rst-high 1 ?? v notes: 1. see table 2.8 on page 32 for the v rst-high specification. 2. for ?i (industrial grade) parts, flash should be pr ogrammed (erase/write) at a minimum temperature of 0 c for reliable flash operation across the ent ire temperature rang e of ?40 to +125 c. this minimum programming temperature does not a pply to ?a (automotive grade) parts. table 2.10. port i/o dc electrical characteristics v regin = 2.7 to 5.25 v, ?40 to +125 c unless otherwise specified parameters conditions min typ max units output high voltage i oh = ?3 ma, port i/o push-pull i oh = ?10 a, port i/o push-pull i oh = ?10 ma, port i/o push-pull v regin ? 0.4 v regin ? 0.02 ? ? ? v regin ? 0.7 ? ? ? v output low voltage v regin = 2.7 v: i ol = 70 a i ol = 8.5 ma v regin = 5.25 v: i ol = 70 a i ol = 8.5 ma ? ? ? ? ? ? ? ? 45 550 40 400 mv input high voltage v regin x 0.7 ? ? v input low ? voltage ??v regin x 0.3 v input ? leakage ? current weak pullup off c8051f52xa/53xa: weak pullup on, v in = 0 v; v regin = 1.8 v c8051f52x/52xa/53x/53xa: weak pullup on, v in = 0 v; v regin = 2.7 v weak pullup on, v in = 0 v; v regin = 5.25 v ? ? ? ? ? 5 20 65 2 15 50 115 a
c8051f52x/f53x 34 rev. 1.4 table 2.11. internal oscillator electrical characteristics v dd = 1.8 to 2.75 v, ?40 to +125 c unless otherwi se specified; using factory-calibrated settings. parameter conditions min typ max units oscillator frequency 1 ifcn = 111b vdd > vregmin 2 ifcn = 111b vdd < vregmin 2 24.5 ? 0.5% 24.5 ? 1.0% 24.5 3 24.5 3 24.5 + 0.5% 24.5 + 1.0% mhz oscillator supply current (from v dd ) oscillator on oscicn[7:6] = 11b ? 800 1100 a oscillator suspend oscicn[7:6] = 00b ztcen = 1 t = 25 c t = 85 c t = 125 c ? ? ? 67 77 117 ? ? 300 a a a oscillator suspend oscicn[7:6] = 00b ztcen = 0 t = 25 c t = 85 c t = 125 c ? ? ? 2 3 50 ? ? ? a a a wake-up time from sus- pend oscicn[7:6] = 00b ztcen = 0 4 ?? 1 s oscicn[7:6] = 00b ztcen = 1 ? 5 ? instruction cycles power supply sensitivity constant temperature ? 0.10 ? %/v temperature sensitivity 5 constant supply tc 1 tc 2 ? ? 5.0 ?0.65 ? ? ppm/c ppm/c 2 notes: 1. see section ?11.2.1. vdd monitor thresholds and minimum vdd? on page 108 for minimum v dd requirements. 2. vregmin is the minimum out put of the voltage regulator for its low setting (reg0cn: reg0md = 0b). see table 2.6, ?voltage regulator electrical specifications,? on page 30. 3. this is the average frequency acro ss the operating temperature range. 4. see ?20.7. internal oscillator su spend mode? on page 212 for ztcen setting in older silicon revisions. 5. use temperature coefficients tc 1 and tc 2 to calculate the new internal oscillator frequency using the following equation: f(t) = f0 x (1 + tc 1 x (t ? t0) + tc 2 x (t ? t0) 2 ) where f0 is the internal oscillator frequency at 25 c and t0 is 25 c.
rev. 1.4 35 c8051f52x/f53x 3. pinout and p ackage definitions figure 3.1. dfn-10 pinout diagram (top view) 3 4 5 1 2 8 7 6 10 9 rst/c2ck p0.0/v ref gnd v dd v regin p0.5/cnvstr/ rx p0.4/ tx p0.3/xtal2 p0.2/xtal1 p0.1/c2d c8051f52xa/52x-c top view gnd 3 4 5 1 2 8 7 6 10 9 rst/c2ck p0.0/v ref gnd v dd v regin p0.5/cnvstr p0.4/ rx p0.3/xtal2/ tx p0.2/xtal1 p0.1/c2d c8051f52x top view gnd
c8051f52x/f53x 36 rev. 1.4 table 3.1. pin definitions for the c8051f52x and c8051f52xa (dfn 10) name pin numbers type description ?f52xa ?f52x-c ?f52x rst / c2ck 11d i/o d i/o device reset. open-drain output of internal por or v dd monitor. an external source can initiate a system reset by driving this pin low for at least the minimum rst low time to generate a system reset, as defined in table 2.8 on page 32. a 1 k ? pullup to v re- gin is recommended. see reset s ources section for a complete description. clock signal for the c2 debug interface. p0.0/ v ref 2 2 d i/o or a in a o or d in port 0.0. see port i/o sectio n for a complete description. external v ref input. see v ref section. gnd 3 3 ground. v dd 4 4 core supply voltage. v regin 5 5 on-chip voltage regulator input. p0.5/rx*/ cnvstr 6 ? d i/o or a in d in port 0.5. see port i/o sectio n for a complete description. external converter start input for the adc0, see section ?4. 12- bit adc (adc0)? on page 52 for a complete description. p0.5/ cnvstr ? 6 d i/o or a in d in port 0.5. see port i/o sectio n for a complete description. external converter start input for the adc0, see section ?4. 12- bit adc (adc0)? on page 52 for a complete description. p0.4/tx* 7 ? d i/o or a in port 0.4. see port i/o sectio n for a complete description. p0.4/rx* ? 7 d i/o or a in port 0.4. see port i/o sectio n for a complete description. p0.3 xtal2 8 ? d i/o or a in d i/o port 0.3. see port i/o sectio n for a complete description. external clock output. for an exte rnal crystal or resonator, this pin is the excitation driver. this pin is the external clock input for cmos, capacitor, or rc oscillator configurations. see section ?14. oscillators? on page 135. note: please refer to section ?20. device specific behavior? on page 210.
rev. 1.4 37 c8051f52x/f53x p0.3/tx*/ xtal2 ? 8 d i/o or a in d i/o port 0.3. see port i/o sectio n for a complete description. external clock output. for an exte rnal crystal or resonator, this pin is the excitation driver. this pin is the external clock input for cmos, capacitor, or rc oscillator configurations. see section ?14. oscillators? on page 135. p0.2 xtal1 9 9 d i/o or a in port 0.2. see port i/o sectio n for a complete description. external clock input. this pin is the external oscillator return for a crystal or resonator. section ?14. oscillators ? on page 135. p0.1/ c2d 10 10 d i/o or a in d i/o port 0.1. see port i/o sectio n for a complete description. bi-directional data signal for the c2 debug interface table 3.1. pin definitions for the c8051f52x and c8051f52xa (dfn 10) (continued) name pin numbers type description ?f52xa ?f52x-c ?f52x note: please refer to section ?20. device specific behavior? on page 210.
c8051f52x/f53x 38 rev. 1.4 figure 3.2. dfn-10 package diagram table 3.2. dfn-10 package diagram dimensions dimension min nom max a 0.80 0.90 1.00 a1 0.00 0.02 0.05 b 0.18 0.25 0.30 d 3.00 bsc. d2 1.50 1.65 1.80 e 0.50 bsc. e 3.00 bsc. e2 2.23 2.38 2.53 l 0.30 0.40 0.50 l1 0.00 ? 0.15 aaa ? ? 0.15 bbb ? ? 0.15 ddd ? ? 0.05 eee ? ? 0.08 notes: 1. all dimensions shown are in millimeters (mm) unless otherwise noted. 2. dimensioning and tolerancing per ansi y14.5m-1994. 3. this drawing conforms to jedec outl ine mo-220, variation veed except for custom features d2, e2, and l, whic h are toleranced per supplier designation. 4. recommended card reflow profile is per the jedec/ipc j-std-020 specification for small body components. ?
rev. 1.4 39 c8051f52x/f53x figure 3.3. dfn-10 landing diagram table 3.3. dfn-10 landing diagram dimensions dimension min max c1 2.90 3.00 e0 . 5 0 b s c . x1 0.20 0.30 x2 1.70 1.80 y1 0.70 0.80 y2 2.45 2.55 notes: general 1. all dimensions shown are in milli meters (mm) unless otherwise noted. 2. this land pattern design is based on the ipc-7351 guidelines. solder mask design 3. all metal pads are to be non-solder mask defined (nsmd). clearance between the solder mask and the metal pa d is to be 60 m minimum, all the way around the pad. stencil design 4. a stainless steel, laser-cut and electr o-polished stencil with trapezoidal walls should be used to assure good solder paste release. 5. the stencil thickness should be 0.125 mm (5 mils). 6. the ratio of stencil aperture to land pad size should be 1:1 for all perimeter pads. 7. a 4x1 array of 1.60 x 0.45 mm openings on 0.65 mm pitch should be used for the center ground pad. card assembly 8. a no-clean, type-3 solder paste is recommended. 9. the recommended card reflow profile is per the jedec/ipc j-std-020 specification for small body components.
c8051f52x/f53x 40 rev. 1.4 figure 3.4. tssop-20 pinout diagram (top view) table 3.4. pin definitions for the c8051f53x and c805153xa (tssop 20) name pin numbers type description ?f53xa ?f53x-c ?f53x p0.2 1 1 d i/o or a in port 0.2. see port i/o sectio n for a complete description. p0.1 2 2 d i/o or a in port 0.1. see port i/o sectio n for a complete description. rst / c2ck 33d i/o d i/o device reset. open-drain output of internal por or v dd monitor. an external source can initiate a system reset by driving this pin low for at least the minimum rst low time to generate a system reset, as defined in table 2.8 on page 32. a 1 k ? pullup to v re- gin is recommended. see reset sources section for a complete description. clock signal for the c2 debug interface. p0.0/ v ref 4 4 d i/o or a in a o or d in port 0.0. see port i/o sectio n for a complete description. external v ref input. see v ref section. gnd 5 5 ground. v dd 6 6 core supply voltage. *note: please refer to section ?20. device specific behavior? on page 210. p0.2 p0.3 p0.4/ tx p0.5/ rx p0.6/c2d p0.7/xtal1 p1.0/xtal2 p1.1 p1.2/cnvstr p1.3 c8051f53xa/53x-c p0.1 rst/c2ck p0.0/v ref gnd v dd v regin p1.7 p1.6 p1.5 p1.4 1 2 3 4 5 6 7 8 9 10 20 19 18 17 16 15 14 13 12 11 p0.2 p0.3/ tx p0.4/ rx p0.5 p0.6/c2d p0.7/xtal1 p1.0/xtal2 p1.1 p1.2/cnvstr p1.3 c8051f53x p0.1 rst/c2ck p0.0/v ref gnd v dd v regin p1.7 p1.6 p1.5 p1.4 1 2 3 4 5 6 7 8 9 10 20 19 18 17 16 15 14 13 12 11
rev. 1.4 41 c8051f52x/f53x v regin 7 7 on-chip voltage regulator input. p1.7 8 8 d i/o or a in port 1.7. see port i/o sectio n for a complete description. p1.6 9 9 d i/o or a in port 1.6. see port i/o sectio n for a complete description. p1.5 10 10 d i/o or a in port 1.5. see port i/o sectio n for a complete description. p1.4 11 11 d i/o or a in port 1.4. see port i/o sectio n for a complete description. p1.3 12 12 d i/o or a in port 1.3. see port i/o sectio n for a complete description. p1.2/ cnvstr 13 13 d i/o or a in d in port 1.2. see port i/o sectio n for a complete description. external converter start input for the adc0, see section ?4. 12- bit adc (adc0)? on page 52 for a complete description. p1.1 14 14 d i/o or a in port 1.1. see port i/o sectio n for a complete description. p1.0/ xtal2 15 15 d i/o or a in d i/o port 1.0. see port i/o sectio n for a complete description. external clock output. for an exte rnal crystal or resonator, this pin is the excitation driver. this pin is the external clock input for cmos, capacitor, or rc oscillator configurations. see section ?14. oscillators? on page 135. p0.7/ xtal1 16 16 d i/o or a in a in port 0.7. see port i/o sectio n for a complete description. external clock input. this pin is the external oscillator return for a crystal or resonator. section ?14. oscillators ? on page 135. p0.6/ c2d 17 17 d i/o or a in d i/o port 0.6. see port i/o sectio n for a complete description. bi-directional data signal for the c2 debug interface. p0.5/rx* 18 ? d i/o or a in port 0.5. see port i/o sectio n for a complete description. p0.5 ? 18 d i/o or a in port 0.5. see port i/o sectio n for a complete description. table 3.4. pin definitions for the c8051f53x and c805153xa (tssop 20) (continued) name pin numbers type description ?f53xa ?f53x-c ?f53x *note: please refer to section ?20. device specific behavior? on page 210.
c8051f52x/f53x 42 rev. 1.4 p0.4/tx* 19 ? d i/o or a in port 0.4. see port i/o sectio n for a complete description. p0.4/rx* ? 19 d i/o or a in port 0.4. see port i/o sectio n for a complete description. p0.3 20 ? d i/o or a in port 0.3. see port i/o sectio n for a complete description. p0.3/tx* ? 20 d i/o or a in port 0.3. see port i/o sectio n for a complete description. table 3.4. pin definitions for the c8051f53x and c805153xa (tssop 20) (continued) name pin numbers type description ?f53xa ?f53x-c ?f53x *note: please refer to section ?20. device specific behavior? on page 210.
rev. 1.4 43 c8051f52x/f53x figure 3.5. tssop-20 package diagram table 3.5. tssop-20 package diagram dimensions symbol min nom max a? ?1 . 2 0 a1 0.05 ? 0.15 a2 0.80 1.00 1.05 b 0.19 ? 0.30 c 0.09 ? 0.20 d 6.40 6.50 6.60 e 0.65 bsc. e 6.40 bsc. e1 4.30 4.40 4.50 l 0.45 0.60 0.75 ? 10 ?8 aaa 0.10 bbb 0.10 ddd 0.20 notes: 1. all dimensions shown are in millimeters (mm). 2. dimensioning and tolerancing per ansi y14.5m-1994. 3. this drawing conforms to jede c outline mo-153, variation ac. 4. recommended card reflow profile is per the jedec/ipc j-std-020 specification for small body components. ??
c8051f52x/f53x 44 rev. 1.4 figure 3.6. tssop-20 landing diagram table 3.6. tssop-20 landing diagram dimensions symbol min max c 5.80 5.90 e0 . 6 5 b s c . x1 0.35 0.45 y1 1.35 1.45 notes: general 1. all dimensions shown are in mill imeters (mm) unless otherwise noted. 2. this land pattern design is based on the ipc-7351 guidelines. solder mask design 3. all metal pads are to be non-solder mask defined (nsmd). clearance between the solder mask and the metal pad is to be 60 m minimum, all the way around the pad. stencil design 4. a stainless steel, laser-cut and el ectro-polished stencil with trapezoidal walls should be used to assure good solder paste release. 5. the stencil thickness should be 0.125 mm (5 mils). 6. the ratio of stencil aperture to land pad size should be 1:1 for all perimeter pads. card assembly 7. a no-clean, type-3 solder paste is recommended. 8. the recommended card reflow prof ile is per the jedec/ipc j-std- 020 specification for small body components.
rev. 1.4 45 c8051f52x/f53x figure 3.7. qfn-20 pinout diagram (top view) 3 4 5 1 2 8 9 10 6 7 13 12 11 15 14 18 19 20 16 17 rst/c2ck p0.0/v ref gnd v dd v regin p1.7 p1.6 p1.5 p1.4 p1.3 p1.2/cnvstr p1.1 p1.0/xtal2 p0.7/xtal1 p0.6/c2d p0.5 p0.4/ rx p0.3/ tx p0.2 p0.1 gnd c8051f53x top view 3 4 5 1 2 8 9 10 6 7 13 12 11 15 14 18 19 20 16 17 rst/c2ck p0.0/v ref gnd v dd v regin p1.7 p1.6 p1.5 p1.4 p1.3 p1.2/cnvstr p1.1 p1.0/xtal2 p0.7/xtal1 p0.6/c2d p0.5/ rx p0.4/ tx p0.3 p0.2 p0.1 gnd c8051f53xa/53x-c top view
c8051f52x/f53x 46 rev. 1.4 table 3.7. pin definitions for the c8051f53x and c805153xa (qfn 20) name pin numbers type description ?f53xa ?f53x-c ?f53x rst / c2ck 11d i/o d i/o device reset. open-drain output of internal por or v dd monitor. an external source can initiate a system reset by driving this pin low for at least the minimum rst low time to generate a system reset, as defined in table 2.8 on page 32. a 1 k ? pullup to v re- gin is recommended. see reset sources section for a complete description. clock signal for the c2 debug interface. p0.0/ v ref 2 2 d i/o or a in a o or d in port 0.0. see port i/o sectio n for a complete description. external v ref input. see v ref section. gnd 3 3 ground. v dd 4 4 core supply voltage. v regin 5 5 on-chip voltage regulator input. p1.7 6 6 d i/o or a in port 1.7. see port i/o sectio n for a complete description. p1.6 7 7 d i/o or a in port 1.6. see port i/o sectio n for a complete description. p1.5 8 8 d i/o or a in port 1.5. see port i/o sectio n for a complete description. p1.4 9 9 d i/o or a in port 1.4. see port i/o sectio n for a complete description. p1.3 10 10 d i/o or a in port 1.3. see port i/o sectio n for a complete description. p1.2/ cnvstr 11 11 d i/o or a in d in port 1.2. see port i/o sectio n for a complete description. external converter start input for the adc0, see section ?4. 12- bit adc (adc0)? on page 52 for a complete description. p1.1 12 12 d i/o or a in port 1.1. see port i/o sectio n for a complete description. note: please refer to section ?20. device specific behavior? on page 210.
rev. 1.4 47 c8051f52x/f53x p1.0/ xtal2 13 13 d i/o or a in d i/o port 1.0. see port i/o sectio n for a complete description. external clock output. for an exte rnal crystal or resonator, this pin is the excitation driver. this pin is the external clock input for cmos, capacitor, or rc osci llator configurat ions. section ?14. oscillators? on page 135. p0.7/ xtal1 14 14 d i/o or a in port 0.7. see port i/o sectio n for a complete description. external clock input. this pin is the external oscillator return for a crystal or resonator. see oscillator section. p0.6/ c2d 15 15 d i/o or a in d i/o port 0.6. see port i/o sectio n for a complete description. bi-directional data signal for the c2 debug interface. p0.5/rx* 16 ? d i/o or a in port 0.5. see port i/o sectio n for a complete description. p0.5 ? 16 d i/o or a in port 0.5. see port i/o sectio n for a complete description. p0.4/tx* 17 ? d i/o or a in port 0.4. see port i/o sectio n for a complete description. p0.4/rx* ? 17 d i/o or a in port 0.4. see port i/o sectio n for a complete description. p0.3 18 ? d i/o or a in port 0.3. see port i/o sectio n for a complete description. p0.3/tx* ? 18 d i/o or a in port 0.3. see port i/o sectio n for a complete description. p0.2 19 19 d i/o or a in port 0.2. see port i/o sectio n for a complete description. p0.1 20 20 d i/o or a in port 0.1. see port i/o sectio n for a complete description. table 3.7. pin definitions for the c8051f53x and c805153xa (qfn 20) (continued) name pin numbers type description ?f53xa ?f53x-c ?f53x note: please refer to section ?20. device specific behavior? on page 210.
c8051f52x/f53x 48 rev. 1.4 figure 3.8. qfn-20 package diagram* *note: the package dimensions are given in table 3.8, ?qfn-20 package diagram dimensions,? on page 49.
rev. 1.4 49 c8051f52x/f53x table 3.8. qfn-20 package diagram dimensions dimension min nom max a 0.80 0.90 1.00 a1 0.00 0.02 0.05 b 0.18 0.25 0.30 d 4.00 bsc. d2 2.55 2.70 2.85 e 0.50 bsc. e 4.00 bsc. e2 2.55 2.70 2.85 l 0.30 0.40 0.50 l1 0.00 ? 0.15 aaa ? ? 0.15 bbb ? ? 0.10 ddd ? ? 0.05 eee ? ? 0.08 z ? 0.43 ? y ? 0.18 ? notes: 1. all dimensions shown are in millime ters (mm) unless otherwise noted. 2. dimensioning and tolerancing per ansi y14.5m-1994. 3. this drawing conforms to jedec outline mo-220, variation vggd except for custom features d2, e2, z, y, l, and l1, which are toleranced per supplier designation. 4. recommended card reflow profile is per the jedec/ipc j-std-020 specification for small body components.
c8051f52x/f53x 50 rev. 1.4 figure 3.9. qfn-20 landing diagram* note: the landing dimensions are given in table 3.9, ?qfn-20 landing diagram dimensions,? on page 51.
rev. 1.4 51 c8051f52x/f53x table 3.9. qfn-20 landing diagram dimensions symbol min max c1 3.90 4.00 c2 3.90 4.00 e 0.50 bsc. x1 0.20 0.30 x2 2.75 2.85 y1 0.65 0.75 y2 2.75 2.85 notes: general 1. all dimensions shown are in millimeters (mm) unless otherwise noted. 2. this land pattern design is based on the ipc-7351 guidelines. solder mask design 3. all metal pads are to be non-solder mask defined (nsmd). clearance between the solder mask and the metal pad is to be 60 m minimum, all the way around the pad. stencil design 4. a stainless steel, laser-cut and electro-polished stencil with trapezoidal walls should be used to assure good solder paste release. 5. the stencil thickness should be 0.125 mm (5 mils). 6. the ratio of stencil aperture to land pad size should be 1:1 for all perimeter pads. 7. a 2x2 array of 1.10 x 1.10 mm openings on 1.30 mm pitch should be used for the center ground pad. card assembly 8. a no-clean, type-3 solder paste is recommended. 9. the recommended card reflow profile is per the jedec/ipc j-std- 020 specification for small body components.
c8051f52x/f53x 52 rev. 1.4 4. 12-bit adc (adc0) the adc0 on the c8051f52x/f52xa/f53x/f53xa family consists of an analog multiplexer (amux0) with 16/6 total input selections, and a 200 ksps, 12-bit successive-approximation-regi ster (sar) adc with inte- grated track-and-hold, programmable window detector, programmable gain, and hardware accumulator. the adc0 subsystem has a special burst mode which can automatically enable adc0, capture and accu- mulate samples, then place adc0 in a low power shutdown mode without cp u intervention. the amux0, data conversion modes, and window detector are all configurable under software control via the special function registers shown in figure 4.1. adc0 inputs are single-ended and may be configured to measure p0.0-p1.7, the temperature sensor output, v dd , or gnd with respect to gnd. the voltage reference for the adc is selected as described in section ?5. voltage reference? on page 72. adc0 is enabled when the ad0en bit in the adc0 control register (adc0cn) is set to logic 1, or when performing conversions in burst mode. adc0 is in low power shutdown when ad0en is logic 0 and no burst mode conversions are taking place. figure 4.1. adc0 functional block diagram 4.1. analog multiplexer amux0 selects the input channel to the adc. any of the following may be selected as an input: p0.0 ? p1.7, the on-chip temperature sensor, the core power supply (v dd ), or ground (gnd). adc0 is single- ended and all signals measured are with respect to gnd. the adc0 input channels are selected using the adc0mx register as described in sfr definition 4.4. important note about adc0 input configuration: port pins selected as adc0 inputs should be config- ured as analog inputs, and should be skipped by the digital crossbar. to configure a port pin for analog input, set to 0 the corresponding bit in register pnmdin (for n = 0,1). to force the crossbar to skip a port pin, set to 1 the corresponding bit in register pnskip (for n = 0,1). see section ? 13. port input/output? on page 120 for more port i/o configuration details. adc0cn ad0cm0 ad0cm1 ad0ljst ad0wint ad0busy ad0int bursten ad0en start conversion vdd 19-to-1 amux0 vdd p0.0 p0.7* p1.0* p1.7* adc0mx adc0mx4 adc0mx3 adc0mx2 adc0mx1 adc0mx0 gnd temp sensor adc0tk ad0pwr3 ad0pwr2 ad0pwr1 ad0pwr0 ad0tm1 ad0tm0 ad0tk1 ad0tk0 burst mode logic start conversion burst mode oscillator 25 mhz max sysclk fclk *available on ?f53x/?f53xa devices 00 ad0busy (w) 10 cnvstr input timer 2 overflow 11 01 timer 1 overflow 12-bit sar adc ref fclk adc0h 32 adc0lth ad0wint adc0ltl adc0gth adc0gtl adc0l adc0cf gainen ad0rpt0 ad0rpt1 ad0sc0 ad0sc1 ad0sc2 ad0sc3 ad0sc4 ad0post ad0pre ad0tm1:0 accumulator window compare logic selectable gain p0.6* adc0gnl adc0gnh adc0gna
rev. 1.4 53 c8051f52x/f53x 4.2. temperature sensor an on-chip temperature sensor is included on t he c8051f52x/f52xa/f53x/f53xa devices which can be directly accessed via the adc0 mu ltiplexer. to use adc0 to measure the temperature sensor, the adc multiplexer channel should be configured to connec t to the temperature sensor. the temperature sensor transfer function is shown in fi gure 5.2. the output voltage (v temp ) is the positive adc input selected by bits ad0mx[4:0] in register adc0mx. the tempe bi t in register ref0cn enables/disables the tempera- ture sensor, as described in sfr definition 5.1. while disabled, the temperature s ensor defaults to a high impedance state and any adc measur ements performed on th e sensor will result in meaningless data. refer to table 5.1 for the slope and offset parameters of the temperature sensor. figure 4.2. typical temperature sensor transfer function temperature voltage v temp = ( slope x temp c ) + offset offset ( v at 0 celsius) slope ( v / deg c) temp c = (v temp - offset) / slope
c8051f52x/f53x 54 rev. 1.4 4.3. adc0 operation in a typical system, adc0 is co nfigured using the following steps: 1. if a gain adjustment is required, refer to section ?4.4. selectable gain? on page 60. 2. choose the start of conversion source. 3. choose normal mode or burst mode operation. 4. if burst mode, choose the adc0 idle power state and set the power-up time. 5. choose the tracking mode. note that pre-tracking mode can only be used with normal mode. 6. calculate required settling time and set the post convert-start tracking time using the ad0tk bits. 7. choose the repeat count. 8. choose the output word justificati on (right-justified or left-justified). 9. enable or disable the end of conversion and window comparator interrupts. 4.3.1. starting a conversion a conversion can be initiated in one of four ways, depending on the programmed states of the adc0 start of conversion mode bits (ad0cm1 ? 0) in register adc0cn. conversions may be initiated by one of the fol- lowing: ? writing a 1 to the ad0busy bit of register adc0cn ? a rising edge on the cnvstr input signal (pin p0.6) ? a timer 1 overflow (i.e., ti med continuous conversions) ? a timer 2 overflow (i.e., ti med continuous conversions)  writing a 1 to ad0busy provides software contro l of adc0 whereby conversions are performed "on- demand.? during conversion, the ad0busy bit is set to logic 1 and reset to logic 0 when the conversion is complete. the falling edge of ad0bu sy triggers an interrupt (when enabl ed) and sets the adc0 interrupt flag (ad0int). note: when polling for adc conversion completions, the adc0 in terrupt flag (ad0int) should be used. converted data is available in th e adc0 data registers, adc0h:adc0l, when bit ad0int is logic 1. note that when timer 2 overflows are us ed as the conversion source, low byte overflows are used if timer2 is in 8-bit mode; high byte overflows are used if timer 2 is in 16-bit mode. see section ?18. timers? on page 182 for timer configuration. important note: the cnvstr input pin also functions as port pin p0.5 on c8051f52x/52xa devices and p1.2 on c8051f53x/53xa devices. when the cnvstr in put is used as the adc0 conversion source, port pin p0.5 or p1.2 should be skipped by the digital crossbar. to configure the crossbar to skip p0.5 or p1.2, set to 1 to the appropriate bit in the pnskip register. see section ?13. port input/output? on page 120 for details on port i/o configuration. 4.3.2. tracking modes each adc0 conversion must be prec eded by a minimum tracking time for the converted result to be accu- rate, as shown in table 2.3 on page 28. adc0 has thre e tracking modes: pre-tracking, post-tracking, and dual-tracking. pre-tracking mode provides the mini mum delay between the convert start signal and end of conversion by tracking continuously before the c onvert start signal. this mode requires software man- agement in order to meet minimum tracking requir ements. in post-tracking mode, a programmable track- ing time starts after the convert start signal and is managed by hardware. dual-tracking mode maximizes tracking time by tracking before and after the conver t start signal. figure 4.3 shows examples of the three tracking modes. pre-tracking mode is selected when ad0tm is set to 10b. conversions are started immediately following the convert start signal. adc0 is tracking continu ously when not performing a conversion. software must allow at least the minimum tracking time between each end of conversion and the next convert start signal. the minimum tracking time must also be met prior to the first convert start signal after adc0 is enabled.
rev. 1.4 55 c8051f52x/f53x post-tracking mode is selected w hen ad0tm is set to 01b. a programmable tracking time based on ad0tk is started immediately following the convert start signal. conversions are started after the pro- grammed tracking time ends. after a conversion is complete, adc0 does not track the input. rather, the sampling capacitor remains disconnected from the in put making the input pin high-impedance until the next convert start signal. dual-tracking mode is selected w hen ad0tm is set to 11b. a programmable tracking time based on ad0tk is started immediately following the convert start signal. conversions are started after the pro- grammed tracking time ends. after a conversion is complete, adc0 trac ks continuously until the next con- version is started. depending on the output connected to the adc input, additional tracking time, more than is specified in table 2.3 on page 28, may be required after changing mux settings. see the settling time requirements described in section ?4.3.6. settling time requirements? on page 60. figure 4.3. adc0 tracking modes 4.3.3. timing adc0 has a maximum conversion speed specified in table 2.3 on page 28. adc0 is clocked from the adc0 subsystem clock (fcl k). the source of fclk is select ed based on the bursten bit. when bursten is logic 0, fclk is derived from the curren t system clock. when bursten is logic 1, fclk is derived from the burst mode oscillator, which is an independent clock source whose maximum frequency is specified in table 2.3 on page 28. when adc0 is performing a conversion, it requires a clock source that is typically slower than fclk. the adc0 sar conversion clock (sar clock) is a divided version of fclk. the divide ratio can be configured using the ad0sc bits in the adc0cf register. the maximum sar clock frequency is listed in table 2.3 on page 28. adc0 can be in one of three states at any given time : tracking, converting, or idle. tracking time depends on the tracking mode selected. for pre-tracking mode, tracking is managed by software and adc0 starts conversions immediately following the convert start signal. for post-tracking and dual-tracking modes, the tracking time after the convert start signal is equal to the value determined by the ad0tk bits plus 2 fclk cycles. tracking is immediately followed by a conversion. the adc0 conversion time is always 13 sar clock cycles plus an additional 2 fclk cycles to start and complete a conversion. figure 4.4 shows timing diagrams for a conversion in pre-tracking mo de and tracking plus conversion in post-tracking or dual-tracking mode. in this example, repeat count is set to one. convert start post-tracking ad0tm= 01 track convert idle idle track convert.. pre-tracking ad0tm = 10 track convert track convert ... dual-tracking ad0tm = 11 track convert track track track convert..
c8051f52x/f53x 56 rev. 1.4 figure 4.4. 12-bit adc tracking mode example convert start adc0 state track adc0 state convert time f s1 s2 s12 s13 ... f time f s1 s2 s12 s13 ... f convert f s1 s2 f post-tracking or dual-tracking modes (ad0tk = ?00') pre-tracking mode ad0int flag ad0int flag key f s n equal to one period of fclk. each sn is equal to one period of the sar clock.
rev. 1.4 57 c8051f52x/f53x 4.3.4. burst mode burst mode is a power saving feature that allows adc0 to remain in a very low power state between con- versions. when burst mode is enabled, adc0 wakes from a very low power state, accumulates 1, 4, 8, or 16 samples using an internal burst mode oscillator, then re -enters a very low power state. since the burst mode clock is independent of the system clock, adc0 can perform multiple conversions then enter a very low power state within a single system clock cycle, even if the system clock is slow (e.g. 32.768 khz), or suspended. burst mode is enabled by setting bursten to logic 1. when in burst mode, ad0en controls the adc0 idle power state (i.e., the state adc0 enters when not tracking or performing conversions). if ad0en is set to logic 0, adc0 is powered down after each burst. if ad0en is set to logic 1, adc0 remains enabled after each burst. on each convert start signal, adc0 is awak ened from its idle power state. if adc0 is powered down, it will automatically power up and wait th e programmable po wer-up time controlled by the ad0pwr bits. otherwise, adc0 will start tracking an d converting immediately. figure 4.5 shows an exam- ple of burst mode operation with a slow system clock and a repeat count of 4. important note: when burst mode is enabled, only post-tracking and dual-tracking modes can be used. when burst mode is enabled, a single convert start will initiate a numb er of conversions e qual to th e repeat count. when burst mode is disabled, a convert start is required to initiate each conversion. in both modes, the adc0 end of conversion interrupt flag (ad0int) will be set after ?repea t count? conversions have been accumulated. similarl y, the window comparator will not compare the result to the greater-than and less-than registers until ?repeat count? conversions have been accumulated. note: when using burst mode, care must be taken to iss ue a convert start signal no faster than once every four sysclk periods. this includes external convert start signals.
c8051f52x/f53x 58 rev. 1.4 figure 4.5. 12-bit adc burst mode example with repeat count set to 4 track.. system clock convert start (ad0busy or timer overflow) post-tracking ad0tm = 01 ad0en = 0 powered down powered down t c power-up and idle t c t c t c power-up and idle t c.. dual-tracking ad0tm = 11 ad0en = 0 powered down powered down t c power-up and track t c t c t c power-up and track t c.. ad0pwr post-tracking ad0tm = 01 ad0en = 1 idle idle t c t c t c t c t c.. dual-tracking ad0tm = 11 ad0en = 1 track track t c t c t c t c t c.. t c t c t c t c t = tracking c = converting convert start (cnvstr) post-tracking ad0tm = 01 ad0en = 0 powered down powered down t c power-up and idle power-up and idle t c.. dual-tracking ad0tm = 11 ad0en = 0 powered down powered down t c power-up and track power-up and track t c.. ad0pwr post-tracking ad0tm = 01 ad0en = 1 idle idle t c dual-tracking ad0tm = 11 ad0en = 1 track track t c t c t c t = tracking c = converting idle..
rev. 1.4 59 c8051f52x/f53x 4.3.5. output conversion code the registers adc0h and adc0l contain the high and lo w bytes of the output conversion code. when the repeat count is set to 1, conversion codes are represen ted in 12-bit unsigned integer format and the output conversion code is updated after each conv ersion. inputs are measured from 0 to v ref x 4095/4096. data can be right-justified or left-justified, depending on the setting of the ad0ljst bit (adc0cn.2). unused bits in the adc0h and adc0l registers are set to 0. example codes are shown below for both right-justi- fied and left-justified data. when the adc0 repeat count is greater than 1, the output conversion code represents the accumulated result of the conversions pe rformed and is updated after the last conv ersion in the series is finished. sets of 4, 8, or 16 consecutive samples can be accumulated and represented in unsigned integer format. the repeat count can be selected using the ad0rpt bits in the adc0cf register. the value must be right-jus- tified (ad0ljst = ?0?), and unused bits in the adc0 h and adc0l registers are set to '0'. the following example shows right-justified codes for repeat counts greater than 1. notice that accumulating 2 n samples is equivalent to left-shifting by n bit positions when all samples returned from the adc have the same value. input voltage right-justified adc0h:adc0l (ad0ljst = 0) left-justified adc0h:adc0l (ad0ljst = 1) v ref x 4095/4096 0x0fff 0xfff0 v ref x 2048/4096 0x0800 0x8000 v ref x 2047/4096 0x07ff 0x7ff0 0 0x0000 0x0000 input voltage repeat count = 4 repeat count = 8 repeat count = 16 v ref x 4095/4096 0x3ffc 0x7ff8 0xfff0 v ref x 2048/4096 0x2000 0x4000 0x8000 v ref x 2047/4096 0x1ffc 0x3ff8 0x7ff0 0 0x0000 0x0000 0x0000
c8051f52x/f53x 60 rev. 1.4 4.3.6. settling time requirements a minimum tracking time is required before an accurate conversion can be performe d. this tracking time is determined by the amux0 resistance, the adc0 samp ling capacitance, any exte rnal source resistance, and the accuracy required for the conversion. figure 4.6 shows the equivalent adc0 input circuit. the required adc0 settling time for a given settling accuracy (sa) may be approximated by equation 4.1. when measuring the temperature sensor output, use the settling time specified in table 2.3 on page 28. see table 2.3 on page 28 for adc0 minimum set- tling time requirements. equation 4.1. adc0 settling time requirements where: sa is the settling accuracy, given as a fraction of an lsb (for example, 0.25 to settle within 1/4 lsb) t is the required settling time in seconds r total is the sum of the amux0 resistance and any external source resistance. n is the adc resolution in bits (12). figure 4.6. adc0 equivalent input circuits 4.4. selectable gain adc0 on the c8051f52x/52xa/53x/53xa family of de vices implements a selectable gain adjustment option. by writing a value to the gain adjust address ra nge, the user can select gain values between 0 and 1.016. for example, three analog sources to be measured have full-scale outputs of 5.0 v, 4.0 v, and 3.0 v, respectively. each adc measurement would ideally use the full dynamic range of the adc with an internal voltage reference of 1.5 v or 2.2 v (set to 2.2 v fo r this example). when sele cting signal one (5.0 v full- scale), a gain value of 0.44 (5 v full scale * 0.44 = 2.2 v full scale) provides a full-scale signal of 2.2 v when the input signal is 5.0 v. likewise, a gain value of 0.55 (4 v full scale * 0.55 = 2.2 v full scale) for the second source and 0.73 (3 v full scale * 0.73 = 2.2 v full scale) for the third sour ce provide full-scale adc0 measurements when the input signal is full-scale. additionally, some sensors or other input sources ha ve small part-to-part variations that must be accounted for to achieve accurate results. in this case, the programmable gain value could be used as a calibration value to eliminate these part-to-part variations. t 2 n sa ------ - ?? ?? r total c sample ? ln = r mux c sample rc input = r mux * c sample mux select px.x
rev. 1.4 61 c8051f52x/f53x 4.4.1. calculating the gain value the adc0 selectable gain feature is controlled by 13 bits in three registers. adc0gnh contains the 8 upper bits of the gain value and adc0gnl contains th e 4 lower bits of the gain value. the final gainadd bit (adc0gna.0) controls an optional extra 1/64 (0.0 16) of gain that can be added in addition to the adc0gnh and adc0gnl gain. the adc0gna.0 bit is set to 1 after a power-on reset. the equivalent gain for the adc0gnh, adc0gnl and adc0gna registers is: equation 4.2. equivalent gain from the adc0gnh and adc0gnl registers where: gain is the 12-bit word of ad c0gnh[7:0] and adc0gnl[7:4] gainadd is the value of the gainadd bit (adc0gna.0) gain is the equivalent gain value from 0 to 1.016 for example, if adc0gnh = 0xfc, adc0gnl = 0x00 , and gainadd = '1', gain = 0xfc0 = 4032, and the resulting equation is: the table below equates values in the adc0gnh, ad c0gnl, and adc0gna registers to the equivalent gain using this equation. for any desired gain value, the gain registers can be calculated by: equation 4.3. calculating the adc0gnh and adc0gnl values from the desired gain where: gain is the 12-bit word of ad c0gnh[7:0] and adc0gnl[7:4] gainadd is the value of the gainadd bit (adc0gna.0) gain is the equivalent gain value from 0 to 1.016 when calculating the value of gain to load into the adc0gnh and adc0gnl re gisters, the gainadd bit can be turned on or off to reach a value closer to the desired gain value. adc0gnh value adc0gnl value gainadd value gain value equivalent gain 0xfc (default) 0x00 (default) 1 (default) 4032 + 64 1.0 (default) 0x7c 0x00 1 1984 + 64 0.5 0xbc 0x00 1 3008 + 64 0.75 0x3c 0x00 1 960 + 64 0.25 0xff 0xf0 0 4095 + 0 ~1.0 0xff 0xf0 1 4095 + 64 1.016 gain gain 4096 -------------- - ?? ?? gainadd 1 64 ----- - ?? ?? ? + = gain 4032 4096 ----------- - ?? ?? 1 1 64 ----- - ?? ?? ? + 0.984 0.016+ 1.0 === gain gain gainadd 1 64 ----- - ?? ?? ? ? ?? ?? 4096 ? =
c8051f52x/f53x 62 rev. 1.4 for example, the initial example in th is section requires a gain of 0.44 to convert 5 v full scale to 2.2 v full scale. using equation 4.3: if gainadd is set to 1, this makes the equation: the actual gain from setting gainadd to 1 and ad c0gnh and adc0gnl to 0x6ca is 0.4399. a similar gain can be achieved if gainadd is set to 0 with a different value for adc0gnh and adc0gnl. 4.4.2. setting the gain value the three programmable gain registers are accessed indirectly using the ad c0h and adc0l registers when the gainen bit (adc0cf.0) bit is set. adc0h ac ts as the address register, and adc0l is the data register. the programmable gain registers can only be written to and cannot be read. see gain register definition 4.1, gain register definition 4.2, and gain register definition 4.3 for more information. the gain is programmed using the following steps: 1. set the gainen bit (adc0cf.0) 2. load the adc0h with the adc0g nh, adc0gnl, or adc0gna address. 3. load adc0l with the desired value for the selected gain register. 4. reset the gainen bit (adc0cf.0) ? notes: 1. an adc conversion should not be performed while the gainen bit is set. 2. even with gain enabled, the maximum input voltage must be less than v regin and the maximum voltage of the signal after gain must be less than or equal to v ref . in code, changing the value to 0.44 gain from the previous example looks like: // in ?c?: adc0cf |= 0x01;// gainen = 1 adc0h = 0x04;// load the adc0gnh address adc0l = 0x6c;// load the upper byte of 0x6ca to adc0gnh adc0h = 0x07;// load the adc0gnl address adc0l = 0xa0;// load the lower nibble of 0x6ca to adc0gnl adc0h = 0x08;// load the adc0gna address adc0l = 0x01;// set the gainadd bit adc0cf &= ~0x01;// gainen = 0 ; in assembly orl adc0cf,#01h ; gainen = 1 mov adc0h,#04h; load the adc0gnh address mov adc0l,#06ch ; load the upper byte of 0x6ca to adc0gnh mov adc0h,#07h; load the adc0gnl address mov adc0l,#0a0h ; load the lower nibble of 0x6ca to adc0gnl mov adc0h,#08h; load the adc0gna address mov adc0l,#01h ; set the gainadd bit anl adc0cf,#0feh ; gainen = 0 gain 0.44 gainadd 1 64 ----- - ?? ?? ? ? ?? ?? 4096 ? = gain 0.44 1 1 64 ----- - ?? ?? ? ? ?? ?? 4096 ? 0.424 4096 ? 1738 0 x 06 ca ====
rev. 1.4 63 c8051f52x/f53x gain register definition 4.1. adc0gnh: adc0 selectable gain high byte gain register definition 4.2. adc0gn l: adc0 selectable gain low byte gain register definition 4.3. adc0gna: adc0 additional selectable gain bits7?0 : high byte of selectable gain word. r/w r/w r/w r/w r/w r/w r/w r/w reset value gainh[7:0] 11111100 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 address: 0x04 bits7?4 : lower 4 bits of the selectable gain word. bits3?0 : reserved . must write 0000b. r/w r/w r/w r/w r/w r/w r/w r/w reset value gainl[3:0] reserved reserved reserved reserved 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 address: 0x07 bits7?1 : reserved . must write 0000000b. bit0 : gainadd : additional gain bit. setting this bit adds 1/64 (0.016) gain to the gain value in the adc0gnh and adc0gnl registers. r/w r/w r/w r/w r/w r/w r/w r/w reset value reserved reserved reserved reserved reserved reserved reserved gainadd 00000001 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 address: 0x08
c8051f52x/f53x 64 rev. 1.4 sfr definition 4.4. adc0mx: adc0 channel select bits7?5 : unused . read = 000b; write = don?t care. bits4?0 : ad0mx4?0 : amux0 positive input selection note: only applies to c8051f53x/c8051f53xa parts. r/w r/w r/w r/w r/w r/w r/w r/w reset value - - - ad0mx 00011111 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: 0xbb ad0mx4?0 adc0 input channel 00000 p0.0 00001 p0.1 00010 p0.2 00011 p0.3 00100 p0.4 00101 p0.5 00110 p0.6* 00111 p0.7* 01000 p1.0* 01001 p1.1* 01010 p1.2* 01011 p1.3* 01100 p1.4* 01101 p1.5* 01110 p1.6* 01111 p1.7* 11000 temp sensor 11001 v dd 11010 - 11111 gnd
rev. 1.4 65 c8051f52x/f53x sfr definition 4.5. adc0cf : adc0 configuration bits7?3 : ad0sc4?0 : adc0 sar conversion clock period bits. sar conversion clock is derived from fclk by the following equation, where ad0sc refers to the 5-bit value held in bits ad0sc4 ? 0. sar conversion clock requirements are given in table 2.3 on page 28. bursten = 0: fclk is the current system clock. bursten = 1: fclk is the burst mode oscillator, specified in table 2.3. * or note: round the result up. bits2?1 : ad0rpt1?0 : adc0 repeat count. controls the number of conversions taken and accumulated between adc0 end of conversion (adcint) and adc0 window co mparator (adcwint) interrupts. a convert start is required for each conversion unless burs t mode is enabled. in burst mode, a single convert start can initiate multiple self-timed conversions. results in both modes are accumulated in the adc0h:adc0l register. when ad0rpt1?0 are set to a value other than '00', the ad0ljst bit in the adc0cn register must be set to '0' (right justified). 00: 1 conversion is performed. 01: 4 conversions are performed and accumulated. 10: 8 conversions are performed and accumulated. 11: 16 conversions are performed and accumulated. bit0: gainen : gain enable bit. controls the gain programming. for more information of the usage, refer to the following chapter: section ?4.4. sele ctable gain? on page 60. r/w r/w r/w r/w r/w r/w r/w r/w reset value ad0sc ad0rpt gainen 11111000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: 0xbc ad0sc fclk clk sar -------------------- 1? = clk sar fclk ad 0 sc 1+ ---------------------------- =
c8051f52x/f53x 66 rev. 1.4 sfr definition 4.6. adc0h: adc0 data word msb sfr definition 4.7. adc0l: adc0 data word lsb bits7?0 : adc0 data word high-order bits. ? for ad0ljst = 0 and ad0rpt as follows: 00: bits 3?0 are the upper 4 bits of the 12-bit result. bits 7?4 are 0000b. 01: bits 4?0 are the upper 5 bits of the 14-bit result. bits 7?5 are 000b. 10: bits 5?0 are the upper 6 bits of the 15-bit result. bits 7?6 are 00b. 11: bits 7?0 are the upper 8 bits of the 16-bit result. for ad0ljst = 1 (ad0rpt must be '00'): bits 7? 0 are the most-signific ant bits of the adc0 12-bit result. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: 0xbe bits7?0 : adc0 data word low-order bits. ? for ad0ljst = 0: bits 7 ? 0 are the lower 8 bits of the adc0 accumulated result. for ad0ljst = 1 (ad0rpt must be '00'): bits 7 ? 4 are the lower 4 bits of the 12-bit result. bits 3 ? 0 are 0000b. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: 0xbd
rev. 1.4 67 c8051f52x/f53x sfr definition 4.8. a dc0cn: adc0 control bit7: ad0en : adc0 enable bit. 0: adc0 disabled. adc0 is in low-power shutdown. 1: adc0 enabled. adc0 is active and ready for data conversions. bit6: bursten : adc0 burst mo de enable bit. 0: adc0 burst mode disabled. 1: adc0 burst mode enabled. bit5: ad0int : adc0 conversion complete interrupt flag. 0: adc0 has not completed a data conversi on since the last time ad0int was cleared. 1: adc0 has completed a data conversion. bit4: ad0busy : adc0 busy bit. read: 0: adc0 conversion is complete or a conversion is not currently in progress. ad0int is set to logic 1 on the fa lling edge of ad0busy. 1: adc0 conversion is in progress. write: 0: no effect. 1: initiates adc0 co nversion if ad0cm1 ? 0 = 00b bit3: ad0wint : adc0 window compare interrupt flag. this bit must be cleared by software. 0: adc0 window comparison data match has not occurred since this flag was last cleared. 1: adc0 window comparison data match has occurred. bit2: ad0ljst : adc0 left justify select 0: data in adc0h:adc0l r egisters is right justified. 1: data in adc0h:adc0l registers is left ju stified. this option should not be used with a repeat count greater than 1 (when ad0rpt1 ? 0 is 01b, 10b, or 11b). bits1?0 : ad0cm1?0 : adc0 start of conversion mode select. 00: adc0 conversion initiated on every write of 1 to ad0busy. 01: adc0 conversion initiated on overflow of timer 1. 10: adc0 conversion initiated on rising edge of external cnvstr. 11: adc0 conversion initiated on overflow of timer 2. r/w r/w r/w r/w r/w r/w r/w r/w reset value ad0en bursten ad0int ad0busy ad0win t ad0ljst ad0cm1 ad0cm0 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: (bit addressable) 0xe8
c8051f52x/f53x 68 rev. 1.4 sfr definition 4.9. adc0tk: adc0 tracking mode select bits7?4 : ad0pwr3?0 : adc0 burst power-up time. for bursten = 0: adc0 power state controlled by ad0en. for bursten = 1 and ad0en = 1; adc0 remains enabled and does not enter the very low power state. for bursten = 1 and ad0en = 0: adc0 enters the very low power state as specified in table 2.3 on page 28 and is enabled after each convert start signal. the power up time is programmed according to the following equation: or bits3?2 : ad0tm1?0 : adc0 tracking mode select bits. 00: reserved. 01: adc0 is configured to post-tracking mode. 10: adc0 is configured to pre-tracking mode. 11: adc0 is configured to dual-tracking mode (default). bits1?0 : ad0tk1?0 : adc0 post-track time. post-tracking time is cont rolled by ad0tk as follows: 00: post-tracking time is equal to 2 sar clock cycles + 2 fclk cycles. 01: post-tracking time is equal to 4 sar clock cycles + 2 fclk cycles. 10: post-tracking time is equal to 8 sar clock cycles + 2 fclk cycles. 11: post-tracking time is equal to 16 sar clock cycles + 2 fclk cycles. r/w r/w r/w r/w r/w r/w r/w r/w reset value ad0pwr ad0tm ad0tk 11111111 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: (bit addressable) 0xba ad0pwr tstartup 200 ns ---------------------- 1? = tstartup ad0pwr 1+ ?? 200 ns =
rev. 1.4 69 c8051f52x/f53x 4.5. programmable window detector the adc programmable window detector continuously compares the adc0 output registers to user-pro- grammed limits, and notifies the system when a desired co ndition is detected. this is especially effective in an interrupt-driven system, saving code space and cpu ba ndwidth while delivering faster system response times. the window detector interrupt flag (ad0wint in register adc0cn) can also be used in polled mode. the adc0 greater-than (adc0gth, adc0gtl) and less-than (adc0lth, adc0ltl) registers hold the comparison valu es. the window detector flag can be programmed to indicate when mea- sured data is inside or outside of the user-programmed limits, depending on the contents of the adc0 less-than and adc0 greater-than registers. sfr definition 4.10. adc0gth: adc0 greater-than data high byte sfr definition 4.11. adc0gtl: adc 0 greater-than data low byte bits7?0 : high byte of adc0 greater-than data word. r/w r/w r/w r/w r/w r/w r/w r/w reset value 11111111 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: 0xc4 bits7?0 : low byte of adc0 greater-than data word. r/w r/w r/w r/w r/w r/w r/w r/w reset value 11111111 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: 0xc3
c8051f52x/f53x 70 rev. 1.4 sfr definition 4.12. adc0lth: adc0 less-than data high byte sfr definition 4.13. adc0ltl: adc0 less-than data low byte bits7?0 : high byte of adc0 less-than data word. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: 0xc6 bits7?0 : low byte of adc0 less-than data word. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: 0xc5
rev. 1.4 71 c8051f52x/f53x 4.5.1. window detector in single-ended mode figure 4.7 shows two example window co mparisons for right-justified data with adc0lth:adc0ltl = 0x0200 (512d) and adc0gth:adc0gtl = 0x0100 (256d). the input voltage can range from 0 to v ref x (4095/4096) with respect to gnd, and is represented by a 12-bit unsigned integer value. the repeat count is set to one. in the left exampl e, an ad0wint interrupt will be generated if the adc0 conversion word (adc0h: adc0l) is within the range defined by adc0gth:adc0gtl and adc0lth:adc0ltl (if 0x0100 < adc0h:adc0l < 0x0200) . in the right example, and ad0wint interrupt will be generated if the adc0 conversion word is outside of the range defi ned by the adc0gt and adc0lt registers (if adc0h:adc0l < 0x0100 or adc0h:adc0l > 0x0200). figure 4.8 shows an exam- ple using left-justified data with the same comparison values. figure 4.7. adc window compare example: right-justified single-ended data figure 4.8. adc window compare exampl e: left-justified single-ended data 0x0fff 0x0201 0x0200 0x01ff 0x0101 0x0100 0x00ff 0x0000 0 input voltage (px.x - gnd) vref x (4095/4096) vref x (512/4096) vref x (256/4096) ad0wint=1 ad0wint not affected ad0wint not affected adc0lth:adc0ltl adc0gth:adc0gtl 0x0fff 0x0201 0x0200 0x01ff 0x0101 0x0100 0x00ff 0x0000 0 input voltage (px.x - gnd) vref x (4095/ 4096) vref x (512/4096) vref x (256/4096) ad0wint not affected ad0wint=1 ad0wint=1 adc0h:adc0l adc0h:adc0l adc0gth:adc0gtl adc0lth:adc0ltl 0xfff0 0x2010 0x2000 0x1ff0 0x1010 0x1000 0x0ff0 0x0000 0 input voltage (px.x - gnd) vref x (4095/4096) vref x (512/4096) vref x (256/4096) ad0wint=1 ad0wint not affected ad0wint not affected adc0lth:adc0ltl adc0gth:adc0gtl 0xfff0 0x2010 0x2000 0x1ff0 0x1010 0x1000 0x0ff0 0x0000 0 input voltage (px.x - gnd) vref x (4095/4096) vref x (512/4096) vref x (256/4096) ad0wint not affected ad0wint=1 ad0wint=1 adc0h:adc0l adc0h:adc0l adc0lth:adc0ltl adc0gth:adc0gtl
c8051f52x/f53x 72 rev. 1.4 5. voltage reference the voltage reference mux on c8051f52x/f52xa/f53x/f 53xa devices is configurable to use an exter- nally connected voltage reference, the internal reference voltage generator, or the v dd power supply volt- age (see figure 5.1). the refsl bit in the reference control register (ref0cn) selects the reference source. for an external source or the internal reference applied to the v ref pin, refsl should be set to 0. to use v dd as the reference source, refsl should be set to 1. the biase bit enables th e internal voltage bi as generator, which is used by the adc, temperature sensor, and internal oscillators. this bit is forced to logic 1 w hen any of the aforemen tioned peripherals are enabled. the bias ge nerator may be enabled manually by writing a 1 to th e biase bit in register ref0cn; see sfr definition 5.1 for ref0cn register details. the electrical specifications for the voltage reference circuit are given in table 2.5 on page 29. the internal voltage reference circuit consists of a temperature stable bandgap voltage reference genera- tor and a gain-of-two output buffer amplifier. the output voltage is selectable between 1.5 v and 2.2 v. the internal voltage reference can be driven out on the v ref pin by setting the ref be bit in register ref0cn to a 1 (see figure 5.1). the load seen by the v ref pin must draw less than 200 a to gnd. when using the internal voltage reference, bypass capacitors of 0.1 f and 4.7 f are recommended from the v ref pin to gnd. if the internal reference is not used, the refbe bit should be cleared to 0. electrical specifica- tions for the internal voltage reference are given in table 2.5 on page 29. figure 5.1. voltage reference functional block diagram vref (to adc) to analog mux vdd vref r1 vdd external voltage reference circuit gnd temp sensor en bias generator to adc, internal oscillators en ioscen 0 1 ref0cn refsl tempe biase refbe reflv refbe internal reference en reflv
rev. 1.4 73 c8051f52x/f53x important note about the v ref pin: port pin p0.0 is used as the external v ref input and as an output for the internal v ref . when using either an external voltage referenc e or the internal reference circuitry, p0.0 should be configured as an analog pin, and skipped by the digital crossbar. to configure p0.0 as an ana- log pin, clear bit 0 in register p0mdin to 0. to conf igure the crossbar to skip p0.0, set bit 0 in register p0skip to 1. refer to sect ion ?13. port input/output? on page 12 0 for complete port i/o configuration details. the tempe bit in register ref0cn enables/disables the temperature sensor. while disabled, the temper- ature sensor defaults to a high impedance state and any adc0 measurements performed on the sensor result in mean ingless data. sfr definition 5.1. ref0 cn: reference control bits7?6 : reserved . read = 00b. must write 00b. bit5: ztcen : zero-tempco bias enable bit * . 0: zerotc bias generator automatically enabled when needed. 1: zerotc bias generator forced on. bit4: reflv : voltage reference output level select. this bit selects the output voltage le vel for the internal voltage reference. 0: internal voltage reference set to 1.5 v. 1: internal voltage reference set to 2.2 v. bit3: refsl : voltage reference select. this bit selects the source for the internal voltage reference. 0: v ref pin used as voltage reference. 1: v dd used as voltage reference. bit2: tempe : temperature sensor enable bit. 0: internal temperature sensor off. 1: internal temperature sensor on. bit1: biase : internal analog bias generator enable bit. 0: internal analog bias generator automatically enabled when needed. 1: internal analog bias generator on. bit0: refbe : internal reference buffer enable bit. 0: internal reference buffer disabled. 1: internal reference buffer enabled. internal voltage reference driven on the v ref pin. * note: see section ?20.7. internal oscillator suspend mode? on page 212 for a note related to the ztcen bit in older silicon revisions. r/w r/w r/w r/w r/w r/w r/w r/w reset value reserved reserved ztcen reflv re fsl tempe biase refbe 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: 0xd1
c8051f52x/f53x 74 rev. 1.4 6. voltage regulator (reg0) c8051f52x/f52xa/f53x/f53xadevices include an on -chip low dropout voltage regulator (reg0). the input to reg0 at the v regin pin can be as high as 5.25 v. the outp ut can be selected by software to 2.1 v or 2.6 v. when enabled, the out put of reg0 appears on the v dd pin, powers the microcontroller core, and can be used to power external devices. on reset, reg0 is enabled and can be disabled by software. the input (v regin ) and output (v dd ) of the voltage regulator should both be bypassed with a large capaci- tor (4.7 f + 0.1 f) to ground. these capacitors are required for regulator stability, and will eliminate power spikes and provide any immediate power required by the microcontroller. the settling time associ- ated with the voltage regulator is shown in table 2.6 on page 30. important note: the bypass capacitors are required for the stability of the voltage regulator. the voltage regulator can also generate an interrupt (if enabled by ereg0, eie1.6) that is triggered when- ever the v regin input voltage drops below the dropout threshold (see table 2.6 on page 30). this dropout interrupt has no pending flag. the recommended procedure to use the interrupt is as follows: 1. wait enough time to ensure the v regin input voltage is stable. 2. enable the dropout interrupt (ereg0, eie1.6) and select the proper priority (preg0, eip1.6). 3. if triggered, disable the interrupt in the interrupt service routine (cle ar ereg0, eie1.6) and execute all necessary procedures to put the system in ?safe mode,? leaving the interrupt disabled. 4. the main application, now running in safe mode, should regularly check the dropout bit (reg0cn.0). once it is cleared by the regulator hardware, the application can re-enable the interrupt (ereg0, eie1.6) and return to normal mode operation. figure 6.1. external capacitors for voltage regulator input/output vregin v dd v dd reg0 4.7 f 4.7 f .1 f .1 f
rev. 1.4 75 c8051f52x/f53x sfr definition 6.1. reg0 cn: regulator control bit7 : regdis : voltage regulator disable bit. this bit disables/enables the voltage regulator. 0: voltage regulator enabled. 1: voltage regulator disabled. bit6 : reserved . read = 1b. must write 1b. bit5 : unused . read = 0b. write = don?t care. bit4 : reg0md : voltage regulator mode select bit. this bit selects the voltage regulator output voltage. 0: voltage regulator output is 2.1 v. ? 1: voltage regulator output is 2.6 v (default). bits3?1 : unused . read = 000b. write = don?t care. bit0 : dropout : voltage regulator dropout indicator bit. 0: voltage regulator is not in dropout. 1: voltage regulator is in or near dropout. r/w r/w r r/w r r r r reset value regdis reserved ? reg0md ? ? ? dropout 01010000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: 0xc9
c8051f52x/f53x 76 rev. 1.4 7. comparator c8051f52x/f52xa/f53x/f53xa devices include one on-chip programmable voltage comparator. the comparator is shown in figure 7.1. the comparator offers programmable response time a nd hysteresis, an analog in put multiplexer, and two outputs that are optionally availabl e at the port pins: a synchronous ?latched? output (cp0), or an asyn- chronous ?raw? output (cp0a). the asynchronous cp0a signal is available even when the system clock is not active. this allows the comparator to operate an d generate an output with the device in stop or sus- pend mode. when assigned to a port pin, the comp arator output may be configured as open drain or push-pull (see section ?13.2. port i/ o initialization? on page 126). the comparator may also be used as a reset source (see section ?11.5. comparator reset? on page 110). the comparator inputs are selected in the cpt0 mx register (sfr definition 7.2). the cmx0p3 ? cmx0p0 bits select the comparator0 positive input; the cmx0n3 ? cmx0n0 bits select the comparator0 negative input. important note about comparator inputs: the port pins selected as comparator inputs should be con- figured as analog inputs in their associated port conf iguration register and configured to be skipped by the crossbar (for details on port configuration, see se ction ?13.3. general purpose port i/o? on page 128). figure 7.1. comparator functional block diagram the comparator output can be polled in softwa re, used as an interrupt source , internal oscillator suspend awakening source and/or routed to a port pin. when routed to a port pin, the comparator output is avail- able asynchronous or synchronous to the system cloc k; the asynchronous output is available even in stop or suspend mode (with no system clock acti ve). when disabled, the comparator output (if assigned to a port i/o pin via the crossbar) defaults to the logic low state, and its supply current falls to vdd cpt0cn reset decision tree + - crossbar interrupt logic q q set clr d q q set clr d (synchronizer) gnd cp0 + cp0 - p0.1 p0.3 p0.5 p0.7* cp0en cp0out cp0rif cp0fif cp0hyp1 cp0hyp0 cp0hyn1 cp0hyn0 cpt0mx cmx0n3 cmx0n2 cmx0n1 cmx0n0 cmx0p3 cmx0p2 cmx0p1 cmx0p0 cpt0md cp0rie cp0fie cp0md1 cp0md0 cp0 cp0a cp0 rising-edge cp0 falling-edge cp0 interrupt p1.1* p1.3* p1.5* p1.7* p0.0 p0.2 p0.4 p0.6* p1.0* p1.2* p1.4* p1.6* *available in 'f53x/'f53xa parts
rev. 1.4 77 c8051f52x/f53x less than 100 na. see section ?13.1. priority crossbar decoder? on page 122 for details on configuring comparator outputs via the digital crossbar. comparator inputs can be externally driven from ? 0.25 v to (v regin ) + 0.25 v without damage or upset. the complete comparator electrical specifications are given in table 2.7 on page 31. the comparator response time may be configured in software via the cptnmd register (see sfr defini- tion 7.3). selecting a longer response time reduce s the comparator supply current. see table 2.7 on page 31 for complete timing and current consumption specifications. figure 7.2. comparator hysteresis plot the comparator hysteresis is software-programmabl e via its comparator cont rol register cpt0cn. the user can program both the amount of hysteresis voltage (referred to the input voltage) and the positive and negative-going symmetry of this hyst eresis around the threshold voltage. the comparator hysteresis is programmed using bits3 ? 0 in the comparator control register cpt0cn (shown in sfr definition 7.1). the amount of negative hysteresis voltage is determined by the settings of the cp0hyn bits. as shown in table 2.7 on page 31, se ttings of 20, 10 or 5 mv of negative hysteresis can be programmed, or negative hysteresis can be disabled. in a similar way, the amou nt of positive hysteresis is determined by the setting the cp0hyp bits. comparator interrupts can be genera ted on both rising-e dge and falling-edge output transitions. (for inter- rupt enable and priority control, see section ?10. interrupt handler? on p age 98). the cp0fif flag is set to logic 1 upon a comparator falling-edge detect, and the cp0rif flag is set to logic 1 upon the comparator rising-edge detect. once set, these bits remain set until cleared by software. the output state of the com- parator can be obtained at any time by reading the cp0out bit. the comparator is enabled by setting the cp0en bit to logic 1 and is disabled by clearing this bit to logic 0. when the comparator is enabled, the internal oscillator is awakened from suspend mode if the comp arator output is logic 0. positive hysteresis voltage (programmed with cp0hyp bits) negative hysteresis voltage (programmed by cp0hyn bits) vin- vin+ inputs circuit configuration + _ cp0+ cp0- cp0 vin+ vin- out v oh positive hysteresis disabled maximum positive hysteresis negative hysteresis disabled maximum negative hysteresis output v ol
c8051f52x/f53x 78 rev. 1.4 note that false rising edges and falling edges can be detected when the comparator is first powered-on or if changes are made to the hy steresis or response time control bits. therefore, it is recommended that the rising-edge and falling-edge flags be explicitly cleared to logic 0 a sh ort time after the comparator is enabled or its mode bits have been changed. this powe r up time is specified in table 2.7 on page 31. sfr definition 7.1. cpt0 cn: comparator0 control bit7: cp0en : comparator0 enable bit. 0: comparator0 disabled. 1: comparator0 enabled. bit6: cp0out : comparator0 output state flag. 0: voltage on cp0+ < cp0?. 1: voltage on cp0+ > cp0?. bit5: cp0rif : comparator0 rising-edge flag. 0: no comparator0 rising edge has occurr ed since this flag was last cleared. 1: comparator0 rising edge has occurred. bit4: cp0fif : comparator0 fa lling-edge flag. 0: no comparator0 falling-e dge has occurred since this flag was last cleared. 1: comparator0 falling-edge has occurred. bits3?2 : cp0hyp1?0 : comparator0 positive hysteresis control bits. 00: positive hysteresis disabled. 01: positive hysteresis = 5 mv. 10: positive hysteresis = 10 mv. 11: positive hysteresis = 20 mv. bits1?0 : cp0hyn1?0 : comparator0 negative hysteresis control bits. 00: negative hysteresis disabled. 01: negative hysteresis = 5 mv. 10: negative hysteresis = 10 mv. 11: negative hysteresis = 20 mv. r/w r r/w r/w r/w r/w r/w r/w reset value cp0en cp0out cp0rif cp0fif cp0hyp1 cp0hyp0 cp0hyn1 cp0hyn0 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: 0x9b
rev. 1.4 79 c8051f52x/f53x sfr definition 7.2. cpt0mx: comparator0 mux selection bits7?4 : cmx0n3?cmx0n0 : comparator0 negative input mux select. these bits select which port pin is used as the comparator0 negative input. *note: available only on the c8051f53x/53xa devices bits1?0 : cmx0p3?cmx0p0 : comparator0 positive input mux select. these bits select which port pin is us ed as the comparator0 positive input. *note: available only on the c8051f53x/53xa devices. r/w r/w r/w r/w r/w r/w r/w r/w reset value cmx0n3 cmx0n2 cmx0n1 cmx0n0 cmx0 p3 cmx0p2 cmx0p1 cmx0p0 01110111 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: 0x9f cmx0n3 cmx0n2 cmx0n1 cmx0n0 negative input 0000 p0.1 0001 p0.3 0010 p0.5 0011 p0.7* 0100 p1.1* 0101 p1.3* 0110 p1.5* 0111 p1.7* cmx0p3 cmx0p2 cmx0p1 cmx0p0 positive input 0000 p0.0 0001 p0.2 0010 p0.4 0011 p0.6* 0100 p1.0* 0101 p1.2* 0110 p1.4* 0111 p1.6*
c8051f52x/f53x 80 rev. 1.4 sfr definition 7.3. cpt0md: comparator0 mode selection bit7: reserved . read = 0b. must write 0b. bit6: unused . read = 0b. write = don?t care. bit5: cp0rie : comparator rising-edge interrupt enable. 0: comparator rising-edge interrupt disabled. 1: comparator rising-edge interrupt enabled. bit4: cp0fie : comparator falling-edge interrupt enable. 0: comparator falling-edge interrupt disabled. 1: comparator falling-edge interrupt enabled. note: it is necessary to enable both cp0xie and the correspondent ecpx bit located in eie1 sfr. bits3?2 : unused . read = 00b. write = don?t care. bits1?0 : cp0md1?cp0md0 : comparator0 mode select these bits select the response time for comparator0. note: rising edge response times are appro ximately double the falling edge response times. r/w r/w r/w r/w r/w r/w r/w r/w reset value reserved ? cp0rie cp0fie ? ? cp0md1 cp0md0 00000010 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: 0x9d mode cp0md1 cp0md0 cp0 falling edge response time (typ) 0 0 0 fastest response time 101 ? 210 ? 3 1 1 lowest power consumption
rev. 1.4 81 c8051f52x/f53x 8. cip-51 microcontroller the mcu system controller core is the cip-51 microcon troller. the cip-51 is fully compatible with the mcs-51? instruction set. standard 803x/805x assemblers and compilers can be used to develop soft- ware. the c8051f52x/f52xa/f53x/f53xa family has a superset of all the peripherals included with a stan- dard 8051. see section ?1. system overview? on page 13 for more information about the available peripherals. the cip-51 includes on-chip debug hardw are which interfaces directly with the analog and digital subsystems, providing a comple te data acquisition or control-syste m solution in a si ngle integrated circuit. the cip-51 microcontroller core implements the standard 8051 organization and peripherals as well as additional custom peripherals and fu nctions to extend its capability (s ee figure 8.1 for a block diagram). the cip-51 core includes the following features: figure 8.1. cip-51 block diagram ? fully compatible with mcs-51 instruction set ? 25 mips peak throughput ? 256 bytes of internal ram ? extended interrupt handler ? reset input ? power management modes ? integrated debug logic ? program and data memory security data bus tmp1 tmp2 prgm. address reg. pc incrementer alu psw data bus data bus memory interface mem_address d8 pipeline buffer data pointer interrupt interface system_irqs emulation_irq mem_control control logic a16 program counter (pc) stop clock reset idle power control register data bus sfr bus interface sfr_address sfr_control sfr_write_data sfr_read_data d8 d8 b register d8 d8 accumulator d8 d8 d8 d8 d8 d8 d8 d8 mem_write_data mem_read_data d8 sram address register sram (256 x 8) d8 stack pointer d8
c8051f52x/f53x 82 rev. 1.4 performance the cip-51 employs a pipelined architecture that grea tly increases its instruction throughput over the stan- dard 8051 architecture. in a standar d 8051, all instructions except for mul and div take 12 or 24 system clock cycles to execute, and usually have a maximum system clock of 12 mhz. by contrast, the cip-51 core executes 70% of its instructions in one or tw o system clock cycles, with no instructions taking more than eight system clock cycles. with the cip-51's system clock runn ing at 25 mhz, it has a peak thro ughput of 25 mips. the cip-51 has a total of 109 instructions. the table below shows the tota l number of instructions th at require each execution time. programming and debugging support in-system programming of the flash program memory and communication with on-chip debug support logic is accomplished via the silicon labs 2-wire (c2) interface. note that the re-progr ammable flash can also be read and written a single byte at a time by the application software using the movc and movx instructions. this feature allows program memory to be used for non-volatile data storage as well as updat- ing program code under software control. the on-chip debug support logic facilitates full speed in-circuit debugging, a llowing the setting of hardware breakpoints, starting, stopping and single stepping th rough program execution (including interrupt service routines), examination of the program's call stack, a nd reading/writing the conten ts of registers and mem- ory. this method of on-chip debugging is completely non-intrusive, requiring no ram, stack, timers, or other on-chip resources. the cip-51 is suppor ted by development tools from silicon laboratories, inc. a nd third party vendors. sili- con laboratories provides an integr ated development environment (ide) including editor, evaluation com- piler, assembler, debugger and programmer. the ide's debugger and programmer interface to the cip-51 via the on-chip debug logic to provide fast and ef ficient in-system device programming and debugging. third party macro assemblers and c compilers are also available. 8.1. instruction set the instruction set of the cip-51 system controller is fully compatible with the standard mcs-51? instruc- tion set. standard 8051 development tools can be used to develop software for the cip-51. all cip-51 instructions are the binary and fu nctional equivalent of their mcs-51? counterparts, including opcodes, addressing modes and effect on psw flags. however, in struction timing is different than that of the stan- dard 8051. 8.1.1. instruction and cpu timing in many 8051 implementations, a distinction is ma de between machine cycles and clock cycles, with machine cycles varying from 2 to 12 clock cycles in length. however, the cip-51 implementation is based solely on clock cycle timing. all instructio n timings are specified in terms of clock cycles. due to the pipelined architecture of the cip-51, most instructions execute in the same number of clock cycles as there are program bytes in the instruction. conditional branch instruct ions take one less clock cycle to complete when the branch is not taken as opposed to when the branch is taken. table 8.1 is the cip-51 instruction set summary, which includes the mnemonic, number of bytes, and number of clock cycles for each instruction. clocks to execute 1 2 2/3 3 3/4 4 4/5 5 8 number of instructions265051473121
rev. 1.4 83 c8051f52x/f53x 8.1.2. movx instruction and program memory the movx instruction is typically used to access data stored in xdata memory space. in the cip-51, the movx instruction can also be used to write or erase on-chip program memory space implemented as re- programmable flash memory. the flas h access feature provides a mechanism for the cip-51 to update program code and use the program memory space for non-volatile data storage. refer to section ?12. flash memory? on page 113 for further details. table 8.1. cip-51 instruction set summary mnemonic description bytes clock cycles arithmetic operations add a, rn add register to a 1 1 add a, direct add direct byte to a 2 2 add a, @ri add indirect ram to a 1 2 add a, #data add immediate to a 2 2 addc a, rn add register to a with carry 1 1 addc a, direct add direct byte to a with carry 2 2 addc a, @ri add indirect ram to a with carry 1 2 addc a, #data add immediate to a with carry 2 2 subb a, rn subtract register from a with borrow 1 1 subb a, direct subtract direct byte from a with borrow 2 2 subb a, @ri subtract indirect ram from a with borrow 1 2 subb a, #data subtract imme diate from a with borrow 2 2 inc a increment a 1 1 inc rn increment register 1 1 inc direct increment direct byte 2 2 inc @ri increment indirect ram 1 2 dec a decrement a 1 1 dec rn decrement register 1 1 dec direct decrement direct byte 2 2 dec @ri decrement indirect ram 1 2 inc dptr increment data pointer 1 1 mul ab multiply a and b 1 4 div ab divide a by b 1 8 da a decimal adjust a 1 1 logical operations anl a, rn and register to a 1 1 anl a, direct and direct byte to a 2 2 anl a, @ri and indirect ram to a 1 2 anl a, #data and immediate to a 2 2 anl direct, a and a to direct byte 2 2 anl direct, #data and immediate to direct byte 3 3 orl a, rn or register to a 1 1 orl a, direct or direct byte to a 2 2 orl a, @ri or indirect ram to a 1 2 orl a, #data or immediate to a 2 2 orl direct, a or a to direct byte 2 2
c8051f52x/f53x 84 rev. 1.4 orl direct, #data or immediate to direct byte 3 3 xrl a, rn exclusive-or register to a 1 1 xrl a, direct exclusive-or direct byte to a 2 2 xrl a, @ri exclusive-or indirect ram to a 1 2 xrl a, #data exclusive-or immediate to a 2 2 xrl direct, a exclusive-or a to direct byte 2 2 xrl direct, #data exclusive-or immediate to direct byte 3 3 clr a clear a 1 1 cpl a complement a 1 2 rl a rotate a left 1 1 rlc a rotate a left through carry 1 1 rr a rotate a right 1 1 rrc a rotate a right through carry 1 1 swap a swap nibbles of a 1 1 data transfer mov a, rn move register to a 1 1 mov a, direct move direct byte to a 2 2 mov a, @ri move indirect ram to a 1 2 mov a, #data move immediate to a 2 2 mov rn, a move a to register 1 1 mov rn, direct move direct byte to register 2 2 mov rn, #data move immediate to register 2 2 mov direct, a move a to direct byte 2 2 mov direct, rn move register to direct byte 2 2 mov direct, direct move direct byte to direct byte 3 3 mov direct, @ri move indirect ram to direct byte 2 2 mov direct, #data move immediate to direct byte 3 3 mov @ri, a move a to indirect ram 1 2 mov @ri, direct move direct byte to indirect ram 2 2 mov @ri, #data move immediate to indirect ram 2 2 mov dptr, #data16 load dptr with 16-bit constant 3 3 movc a, @a+dptr move code byte relative dptr to a 1 3 movc a, @a+pc move code byte relative pc to a 1 3 movx a, @ri move external data (8-bit address) to a 1 3 movx @ri, a move a to external data (8-bit address) 1 3 movx a, @dptr move external data (16-bit address) to a 1 3 movx @dptr, a move a to external data (16-bit address) 1 3 push direct push direct byte onto stack 2 2 pop direct pop direct byte from stack 2 2 xch a, rn exchange register with a 1 1 xch a, direct exchange direct byte with a 2 2 xch a, @ri exchange indirect ram with a 1 2 xchd a, @ri exchange low nibble of indirect ram with a 1 2 table 8.1. cip-51 instruction set summary (continued) mnemonic description bytes clock cycles
rev. 1.4 85 c8051f52x/f53x boolean manipulation clr c clear carry 1 1 clr bit clear direct bit 2 2 setb c set carry 1 1 setb bit set direct bit 2 2 cpl c complement carry 1 1 cpl bit complement direct bit 2 2 anl c, bit and direct bit to carry 2 2 anl c, /bit and complement of direct bit to carry 2 2 orl c, bit or direct bit to carry 2 2 orl c, /bit or complement of direct bit to carry 2 2 mov c, bit move direct bit to carry 2 2 mov bit, c move carry to direct bit 2 2 jc rel jump if carry is set 2 2/3 jnc rel jump if carry is not set 2 2/3 jb bit, rel jump if direct bit is set 3 3/4 jnb bit, rel jump if direct bit is not set 3 3/4 jbc bit, rel jump if direct bit is set and clear bit 3 3/4 program branching acall addr11 absolute subroutine call 2 3 lcall addr16 long subroutine call 3 4 ret return from subroutine 1 5 reti return from interrupt 1 5 ajmp addr11 absolute jump 2 3 ljmp addr16 long jump 3 4 sjmp rel short jump (relative address) 2 3 jmp @a+dptr jump indirect relative to dptr 1 3 jz rel jump if a equals zero 2 2/3 jnz rel jump if a does not equal zero 2 2/3 cjne a, direct, rel compare direct byte to a and jump if not equal 3 4/5 cjne a, #data, rel compare immediate to a and jump if not equal 3 3/4 cjne rn, #data, rel compare immediate to register and jump if not equal 33/4 cjne @ri, #data, rel compare immediate to indirect and jump if not equal 34/5 djnz rn, rel decrement regist er and jump if not zero 2 2/3 djnz direct, rel decrement direct byte and jump if not zero 3 3/4 nop no operation 1 1 table 8.1. cip-51 instruction set summary (continued) mnemonic description bytes clock cycles
c8051f52x/f53x 86 rev. 1.4 8.2. register descriptions following are descriptions of sfrs related to the operati on of the cip-51 system controller. reserved bits should not be set to logic 1. future product versions may use these bits to implement new features in which case the reset value of the bi t will be logic 0, selecting the featur e's default state. detailed descrip- tions of the remaining sfrs are included in the sect ions of the datasheet asso ciated with their correspond- ing system function. notes on registers, operands and addressing modes: rn - register r0 ? r7 of the currently selected register bank. @ri - data ram location addressed indirectly through r0 or r1. rel - 8-bit, signed (two?s complement) offset relative to the first byte of the following instruction. used by sjmp and all conditional jumps. direct - 8-bit internal data location?s address. this could be a direct-access data ram location (0x00 ? 0x7f) or an sfr (0x80 ? 0xff). #data - 8-bit constant #data16 - 16-bit constant bit - direct-accessed bit in data ram or sfr addr11 - 11-bit destination address used by acall and ajmp. the destination mu st be within the same 2 kb page of program memory as the first byte of the following instruction. addr16 - 16-bit destination address used by lcall a nd ljmp. the destination may be anywhere within the 7680 bytes of program memory space. there is one unused opcode (0xa5) that performs the same function as nop. all mnemonics copyrighted ? intel corporation 1980.
rev. 1.4 87 c8051f52x/f53x sfr definition 8.1. sp: stack pointer sfr definition 8.2. dpl: data pointer low byte sfr definition 8.3. dph: data pointer high byte bits7 ? 0 : sp : stack pointer. the stack pointer holds the location of the top of the stack. the stack pointer is incremented before every push operation. the sp r egister defaults to 0x07 after reset. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000111 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: 0x81 bits7?0 : dpl : data pointer low. the dpl register is the low byte of the 16-b it dptr. dptr is used to access indirectly addressed xram and flash memory. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: 0x82 bits7?0 : dph : data pointer high. the dph register is the high byte of the 16-b it dptr. dptr is used to access indirectly addressed xram and flash memory. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: 0x83
c8051f52x/f53x 88 rev. 1.4 sfr definition 8.4. psw: program status word bit7: cy : carry flag. this bit is set when the last arithmetic operat ion resulted in a carry (addition) or a borrow (subtraction). it is cleared to 0 by all other arithmetic operations. bit6: ac : auxiliary carry flag this bit is set when the last arithmetic operati on resulted in a carry into (addition) or a borrow from (subtraction) the high order nibble. it is cleared to 0 by all other arithmetic operations. bit5: f0 : user flag 0. this is a bit-addressable, general purpose flag for use under software control. bits4?3 : rs1?rs0 : register bank select. these bits select which register ban k is used during register accesses. ? bit2: ov : overflow flag. this bit is set to 1 under the following circumstances: ? an add, addc, or subb instructi on causes a sign-change overflow. ? a mul instruction results in an overflow (result is greater than 255). ? a div instruction causes a divide-by-zero condition. the ov bit is cleared to 0 by the add, addc, subb, mul, and div inst ructions in all other cases. bit1: f1 : user flag 1. this is a bit-addressable, general purpose flag for use under software control. bit0: parity : parity flag. this bit is set to 1 if the sum of the eight bits in the accumulator is odd and cleared if the sum is even. r/w r/w r/w r/w r/w r/w r/w r reset value cy ac f0 rs1 rs0 ov f1 parity 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit addressable sfr address: 0xd0 rs1 rs0 register bank address 0 0 0 0x00?0x07 0 1 1 0x08?0x0f 1 0 2 0x10?0x17 1 1 3 0x18?0x1f
rev. 1.4 89 c8051f52x/f53x sfr definition 8.5. acc: accumulator sfr definition 8.6. b: b register 8.3. power management modes the cip-51 core has two software programmable power management modes: idle and stop. idle mode halts the cpu while leaving the peripherals and internal clocks active. in stop mode, the cpu is halted, all interrupts and timers (excep t the missing clock detector) are inactive, and the internal os cillator is stopped (analog peripherals remain in their selected states; the external oscillator is not affected ). since clocks are running in idle mode, power consumption is dependent upon the system clock frequency and the number of peripherals left in active mode before entering idle. stop mode consumes the least power. sfr defini- tion 8.7 describes the power control register (pcon) used to control the cip-51's power management modes. although the cip-51 has idle and stop modes built in (as with any standard 8051 architecture), power management of the entire mcu is better accomplished by enabling/disabling individual peripherals as needed. each analog peripheral can be disabled when not in use and placed in low power mode. digital peripherals, such as timers or serial buses, draw littl e power when they are not in use. turning off the oscil- lators lowers power consumption considerably; however a reset is required to restart the mcu. the c8051f52x/f52xa/f53x/f53xa devices feature a low-power suspend mode, which stops the inter- nal oscillator until a wake ning event occurs. see section ?14.1.1. internal oscillator suspend mode? on page 136 for more information. bits7?0 : acc : accumulator. this register is the accumulator for arithmetic operations. r/w r/w r/w r/w r/w r/w r/w r/w reset value acc.7 acc.6 acc.5 acc.4 acc.3 acc.2 acc.1 acc.0 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit addressable sfr address: 0xe0 bits7?0 : b : b register. this register serves as a second accumu lator for certain arithmetic operations. r/w r/w r/w r/w r/w r/w r/w r/w reset value b.7 b.6 b.5 b.4 b.3 b.2 b.1 b.0 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit addressable sfr address: 0xf0
c8051f52x/f53x 90 rev. 1.4 8.3.1. idle mode setting the idle mode select bit (pcon.0) causes the cip-51 to halt the cpu and enter idle mode as soon as the instruction that sets the bit completes executio n. all internal registers and memory maintain their original data. all analog and digital peripherals can remain active during idle mode. idle mode is terminated when an enabled interrupt is asserted or a reset occurs. the assertion of an enabled interrupt will cause the idle mode selection bit (pcon.0) to be cleared and the cpu to resume operation. the pen ding interrupt will be serviced and the next in struction to be executed after the return from interrupt (reti) will be the instruction immedi ately following the one that se t the idle mode select bit. if idle mode is terminated by an internal or external reset, the cip-51 performs a normal reset sequence and begins program execution at address 0x0000. if enabled, the watchdog timer (wdt) will eventually cause an internal watchdog reset a nd thereby termi- nate the idle mode. this feature protects the system from an unintended permanent shutdown in the event of an inadvertent write to the pcon register. if this behavior is not desired, th e wdt may be disabled by software prior to entering the idle mo de if the wdt was initially configured to allow this operation. this pro- vides the opportunity for additional power savings, allo wing the system to remain in the idle mode indefi- nitely, waiting for an external st imulus to wake up the system. 8.3.2. stop mode setting the stop mode select bit (pcon.1) causes the ci p-51 to enter stop mode as soon as the instruc- tion that sets the bit comp letes execution. in stop mo de the internal oscillator, cpu, and all digital peripher- als are stopped; the st ate of the external oscillator circuit is not affected. each analog peripheral (including the external oscillator circuit) may be shut down individually prior to entering stop mo de. stop mode can only be terminated by an internal or external reset. on reset, the cip-51 performs the normal reset sequence and begins program execution at address 0x0000. if enabled, the missing clock detect or will cause an internal reset and ther eby terminate th e stop mode. the missing clock detector should be disabled if the cpu is to be put to in stop mode for longer than the mcd timeout period of 100 ? s. 8.3.3. suspend mode the c8051f52x/f52xa/f53x/f53xa devices feature a lo w-power suspend mode, which stops the internal oscillator until a wakening event occu rs. see section section ?14.1.1. internal oscillator suspend mode? on page 136 for more information. note: when entering suspend mode, firmware must se t the ztcen bit in ref0cn (sfr definition 5.1).
rev. 1.4 91 c8051f52x/f53x sfr definition 8.7. pcon: power control bits7?2 : reserved . bit1: stop : stop mode select. writing a 1 to this bit will pl ace the cip-51 into stop mode. this bit will always read 0. 1: cip-51 forced into po wer-down mode. (turns of f internal oscillator). bit0: idle : idle mode select. writing a 1 to this bit will pl ace the cip-51 into idle mode. this bit will always read 0. 1: cip-51 forced into idle mode. (shuts off cl ock to cpu, but clock to timers, interrupts, and all peripherals remain active.) r/w r/w r/w r/w r/w r/w r/w r/w reset value reserved reserved reserved reserved reserved reserved stop idle 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: 0x87
c8051f52x/f53x 92 rev. 1.4 9. memory organization and sfrs the memory organization of the c8051f52x/f52xa/f53x/f53xa is similar to that of a standard 8051. there are two separate memory spaces: program memory and data memory. program and data memory share the same address space but are accessed via di fferent instruction types. the memory map is shown in figure 9.1. figure 9.1. memory map 9.1. program memory the cip-51 core has a 64 kb program memory space. the c8051f520/0a/1/1a and c8051f530/0a/1/1a implement 8 kb of this program memory space as in-system, re-programmable flash memory, organized in a contiguous block from addresses 0x0000 to 0x 1fff. addresses above 0x1dff are reserved on the 8 kb devices. the c8051f523/3a/4/4a and c8051f533/3a/4/4a implement 4 kb of flash from addresses 0x0000 to 0x0fff. the c8051f526/6a/7/7a and c8 051f536/6a/7/7a implement 2 kb of flash from addresses 0x0000 to 0x07ff. program memory is normally assumed to be read- only. however, the c8051f52x/f52xa/f53x/f53xa can write to program memory by setting the program store write enable bit (psctl.0) and using the movx write instruction. this feature pr ovides a mechanism for updates to program code and use of the program memory space for non-volatile data storage. refer to section ?12. flash memory? on page 113 for further details. program/data memory (flash) 8 kb flash (in-system programmable in 512 byte sectors) 0x0000 reserved 'f520/0a/1/1a and 'f530/0a/1/1a 0x0000 'f523/3a/4/4a and 'f533/3a/4/4a 4 kb flash (in-system programmable in 512 byte sectors) reserved 'f526/6a/7/7a and 'f536/6a/7/7a 0x0000 2 kb flash (in-system programmable in 512 byte sectors) reserved (direct and indirect addressing) 0x00 0x7f upper 128 ram (indirect addressing only) 0x80 0xff special function register's (direct addressing only) data memory (ram) general purpose registers 0x1f 0x20 0x2f bit addressable lower 128 ram (direct and indirect addressing) 0x30 internal data address space 0x1e00 0x1dff 0x1000 0x0fff 0x0800 0x07ff
rev. 1.4 93 c8051f52x/f53x 9.2. data memory the c8051f52x/f52xa/f53x/f53xaincl udes 256 bytes of internal ram mapped into the data memory space from 0x00 through 0xff. the lower 128 bytes of data memory are used for general purpose regis- ters and scratch pad memory. either direct or indirect addressing may be used to access the lower 128 bytes of data memory. locations 0x00 through 0x 1f are addressable as four banks of general pur- pose registers, each bank consisting of eight byte-wide registers. the next 16 bytes, locations 0x20 through 0x2f, may either be addressed as bytes or as 128 bit locations accessible with the direct address- ing mode. the upper 128 bytes of data memory are accessible only by indirect addressing. this region occupies the same address space as the special function register s (sfrs) but is physically separate from the sfr space. the addressing mode used by an instruction when accessing locations above 0x7f determines whether the cpu accesses the upper 128 bytes of data memory space or the sfrs. instructions that use direct addressing will access the sfr space. instructions using indirect addressing above 0x7f access the upper 128 bytes of data memory. figure 9.1 illustrates the data me mory organization of the c8051f52x/ f52xa/f53x/f53xa. 9.3. general purpose registers the lower 32 bytes of data memory (locations 0x00 through 0x1f) may be addressed as four banks of general-purpose registers. each bank consists of eight byte-wide registers designated r0 through r7. only one of these banks may be enabled at a time. tw o bits in the program status word, rs0 (psw.3) and rs1 (psw.4), select the active register bank (see desc ription of the psw in sfr definition 8.4. psw: pro- gram status word). this allows fast context switching when entering subroutines and interrupt service rou- tines. indirect addressing modes use registers r0 and r1 as index registers. 9.4. bit addressable locations in addition to direct access to data memory organized as bytes, the sixteen data memory locations at 0x20 through 0x2f are also accessible as 128 individually addressable bits. each bit has a bit address from 0x00 to 0x7f. bit 0 of the byte at 0x20 has bit address 0x00 while bit 7 of the byte at 0x20 has bit address 0x07. bit 7 of the byte at 0x2f has bit address 0x7f. a bit access is distinguished from a full byte access by the type of instruction used (bit source or destinat ion operands as opposed to a byte source or destina- tion). the mcs-51? assembly language allows an alternate notation for bit addressing of the form xx.b where xx is the byte address and b is the bit position within the byte. for example, the instruction: mov c, 22.3h moves the boolean value at 0x13 (bit 3 of the byte at location 0x22) into the carry flag. 9.5. stack a programmer's stack can be located anywhere in the 256-byte data memory. the stack area is desig- nated using the stack pointer (sp, 0x81) sfr. the sp will poin t to the last location used. the next value pushed on the stack is placed at sp +1 and then sp is incremented. a re set initializes the stack pointer to location 0x07. therefore, the first value pushed on the st ack is placed at location 0x08, which is also the first register (r0) of register bank 1. thus, if more than one register bank is to be used, the sp should be initialized to a location in the data memory not being used for data storage. the stack depth can extend up to 256 bytes. 9.6. special function registers the direct-access data memory locations from 0x80 to 0xff constitute the sp ecial function registers (sfrs). the sfrs provide control and data exchang e with the cip-51's resources and peripherals. the cip-51 duplicates the sfrs found in a typical 805 1 implementation as well as implementing additional
c8051f52x/f53x 94 rev. 1.4 sfrs used to configure and access the sub-systems uni que to the mcu. this allows the addition of new functionality while retaining compatibility with the mcs-51? instruction set. table 9.1 lists the sfrs imple- mented in the cip-51 system controller. the sfr registers are accessed anytime the direct ad dressing mode is used to access memory locations from 0x80 to 0xff. sfrs with addresses ending in 0x0 or 0x8 (e.g. p0, tcon, ie, etc.) are bit-addressable as well as byte-addressable. all other sfrs are byte -addressable only. unoccupied addresses in the sfr space are reserved for futu re use. accessing these areas will have an indetermin ate effect an d should be avoided. refer to the corresponding pages of the data sheet, as indicated in table 9.2, for a detailed description of each register. table 9.1. special function register (sfr) memory map f8 spi0cn pca0l pca0h pca0cpl0 pca0cph0 vddmon f0 bp0mdinp1mdin eip1 e8 adc0cn pca0cpl1 pca0cph1 pca0cpl2 pca0cph2 rstsrc e0 acc xbr0 xbr1 it01cf eie1 d8 pca0cn pca0md pca0cpm0 pca0cpm1 pca0cpm2 d0 psw ref0cn p0skip p1skip p0mat c8 tmr2cn reg0cn tmr2rll tmr2rlh tmr2l tmr2h p1mat c0 adc0gtl adc0gth adc0ltl adc0lth p0mask b8 ip adc0tk adc0mx adc0cf adc0l adc0 p1mask b0 oscifin oscxcn oscicn oscicl flkey a8 ie clksel a0 spi0cfg spi0ckr spi0dat p0mdout p1mdout 98 scon0 sbuf0 cpt0cn cpt0md cpt0mx 90 p1 linaddr lindata lincf 88 tcon tmod tl0 tl1 th0 th1 ckcon psctl 80 p0 sp dpl dph pcon 0(8) 1(9) 2(a) 3(b) 4(c) 5(d) 6(e) 7(f) (bit address- able)
rev. 1.4 95 c8051f52x/f53x table 9.2. special function registers sfrs are listed in alphabetical order. all undefined sfr locations are reserved register address description page acc 0xe0 accumulator 89 adc0cf 0xbc adc0 configuration 65 adc0cn 0xe8 adc0 control 67 adc0h 0xbe adc0 66 adc0l 0xbd adc0 66 adc0gth 0xc4 adc0 greater-than data high byte 69 adc0gtl 0xc3 adc0 greater-than data low byte 69 adc0lth 0xc6 adc0 less-than data high byte 70 adc0ltl 0xc5 adc0 less-than data low byte 70 adc0mx 0xbb adc0 channel select 64 adc0tk 0xba adc0 tracking mode select 68 b 0xf0 b register 89 ckcon 0x8e clock control 188 clksel 0xa9 clock select 143 cpt0cn 0x9b comparator0 control 78 cpt0md 0x9d comparator0 mode selection 80 cpt0mx 0x9f comparator0 mux selection 79 dph 0x83 data pointer high 87 dpl 0x82 data pointer low 87 eie1 0xe6 extended interrupt enable 1 102 eip1 0xf6 extended in terrupt priority 1 103 flkey 0xb7 flash lock and key 119 ie 0xa8 interrupt enable 100 ip 0xb8 interrupt priority 101 it01cf 0xe4 int0/int1 configuration 105 linaddr 0x92 lin indirect address pointer 172 lincf 0x95 lin master-slave and automatic baud rate selection 173 lindata 0x93 lin indirect data buffer 172 oscicl 0xb3 internal oscillator calibration 138
c8051f52x/f53x 96 rev. 1.4 oscicn 0xb2 internal oscillator control 137 oscxcn 0xb1 external oscillator control 142 p0 0x80 port 0 latch 129 p0mask 0xc7 port 0 mask 131 p0mat 0xd7 port 0 match 131 p0mdin 0xf1 port 0 input mode configuration 129 p0mdout 0xa4 port 0 output mode configuration 130 p0skip 0xd4 port 0 skip 130 p1 0x90 port 1 latch 132 p1mask 0xbf port 1 mask 134 p1mat 0xcf port 1 match 134 p1mdin 0xf2 port 1 input mode configuration 132 p1mdout 0xa5 port 1 output mode configuration 133 p1skip 0xd5 port 1 skip 133 pca0cn 0xd8 pca control 206 pca0cph0 0xfc pca capture 0 high 209 pca0cph1 0xea pca capture 1 high 209 pca0cph2 0xec pca capture 2 high 209 pca0cpl0 0xfb pca capture 0 low 209 pca0cpl1 0xe9 pca capture 1 low 209 pca0cpl2 0xeb pca capture 2 low 209 pca0cpm0 0xda pca module 0 mode 208 pca0cpm1 0xdb pca module 1 mode 208 pca0cpm2 0xdc pca module 2 mode 208 pca0h 0xfa pca counter high 209 pca0l 0xf9 pca counter low 209 pca0md 0xd9 pca mode 207 pcon 0x87 power control 91 psctl 0x8f program store r/w control 119 psw 0xd0 program status word 88 table 9.2. special function registers (continued) sfrs are listed in alphabetical order. all undefined sfr locations are reserved register address description page
rev. 1.4 97 c8051f52x/f53x ref0cn 0xd1 voltage reference control 73 reg0cn 0xc9 voltage regulator control 75 rstsrc 0xef reset source configuration/status 112 sbuf0 0x99 uart0 data buffer 150 scon0 0x98 uart0 control 149 sp 0x81 stack pointer 87 spi0cfg 0xa1 spi configuration 157 spi0ckr 0xa2 spi clock rate control 159 spi0cn 0xf8 spi control 158 spi0dat 0xa3 spi data 160 tcon 0x88 timer/counter control 186 th0 0x8c timer/counter 0 high 189 th1 0x8d timer/counter 1 high 189 tl0 0x8a timer/counter 0 low 189 tl1 0x8b timer/counter 1 low 189 tmod 0x89 timer/counter mode 187 tmr2cn 0xc8 timer/co unter 2 control 193 tmr2h 0xcd timer/counter 2 high 194 tmr2l 0xcc timer/counter 2 low 194 tmr2rlh 0xcb timer/count er 2 reload high 194 tmr2rll 0xca timer/count er 2 reload low 194 vddmon 0xff v dd monitor control 109 xbr0 0xe1 port i/o crossbar control 0 127 xbr1 0xe2 port i/o crossbar control 1 128 table 9.2. special function registers (continued) sfrs are listed in alphabetical order. all undefined sfr locations are reserved register address description page
c8051f52x/f53x 98 rev. 1.4 10. interrupt handler the c8051f52x/f52xa/f53x/f53xa fa mily includes an extende d interrupt system with two selectable pri- ority levels. the allocation of interrupt sources between on-chip peripherals and external input pins varies according to the specific version of the device. each interrupt source has one or more associated interrupt- pending flag(s) located in an sfr. when a peripheral or external source meets a valid interrupt condition, the associated interrupt-pending flag is set to logic 1. if interrupts are enabled for the source, an interrupt req uest is generated when the interrupt-pending flag is set. as soon as execution of the current instructio n is complete, the cpu generates an lcall to a prede- termined address to begin execution of an interrupt se rvice routine (isr). each isr must end with an reti instruction, which returns program execution to the next instruction that would have been executed if the interrupt request had not occurred. if interrupts are not enabled, the interrupt-pending flag is ignored by the hardware and program execution continues as normal. (the interrupt-pending flag is set to logic 1 regard- less of the interrupt's enable/disable state.) each interrupt source can be individually enabled or disabled through the use of an associated interrupt enable bit in the interrupt enable and extended interrupt enable sfrs. however, interrupts must first be globally enabled by setting the ea bit (ie.7) to logic 1 before the individual interrupt enables are recog- nized. setting the ea bit to logic 0 disables all interrupt sources regardless of the individual interrupt- enable settings. note that interrupts which occur wh en the ea bit is set to logic 0 will be held in a pending state, and will not be serviced until the ea bit is set back to logic 1. some interrupt-pending flags are automatically cleare d by the hardware when the cpu vectors to the isr. however, most are not cleared by the hardware and must be cleared by software before returning from the isr. if an interrupt-pending flag remains set after the cpu completes the return-from-interrupt (reti) instruction, a new interr upt request will be gen erated immediately and the cpu will re-enter the isr after the completion of the next instruction. 10.1. mcu interrupt sources and vectors the c8051f52x/f52xa/f53x/f53xa mcus support 15 interrupt sources. software can simulate an inter- rupt by setting any interrupt-pending flag to logic 1. if interrupts are enabled for the flag, an interrupt request will be generated an d the cpu will vector to th e isr address associated with the interr upt-pending flag. mcu interrupt sources, associated vector addresses, priority order, and control bits are summarized in table 10.1 on page 99. refer to the data sheet section associated with a particul ar on-chip peripheral for information regarding valid interrupt conditions for the peripheral and the behavior of its interrupt-pending flag(s). 10.2. interrupt priorities each interrupt source can be individually programmed to one of two priority levels: low or high. a low prior- ity interrupt service routine can be pree mpted by a high priority interrupt. a high priority interrupt cannot be preempted. each interrupt has an associated interrupt priority bit in an sfr (ip or eip1) used to configure its priority level. low priority is th e default. if two interrupts are recognized simultaneously, the interrupt with the higher priority is serviced first. if both interrupts have the same priority level, a fixed priority order is used to arbitrate, given in table 10.1. 10.3. interrupt latency interrupt response time depends on the state of the cpu when the interrupt occurs. pending interrupts are sampled and priority decoded each sys tem clock cycle. therefore, the fa stest possible response time is 5 system clock cycles: 1 clock cycle to detect the interr upt and 4 clock cycles to complete the lcall to the isr. if an interrupt is pending when a reti is execut ed, a single instruction is executed before an lcall is made to service the pending interrupt. therefore, the maximum response time for an interrupt (when no other interrupt is currently being serviced or the new in terrupt is of greater priority) occurs when the cpu is performing an reti instruct ion followed by a div as the next instructio n. in this case, th e response time is
rev. 1.4 99 c8051f52x/f53x 18 system clock cycles: 1 clock cycle to detect the in terrupt, 5 clock cycles to execute the reti, 8 clock cycles to complete the div instruction, and 4 clock cycles to execute the lcall to the isr. if the cpu is executing an isr for an interr upt with equal or higher pr iority, the new interrupt will not be serviced until the current isr completes, including the reti and following instruction. table 10.1. interrupt summary interrupt source interrupt vector priority order pending flag bit addressable? cleared by hw? enable flag priority control reset 0x0000 top none n/a n/a always enabled always highest external interrupt 0(int0 ) 0x0003 0 ie0 (tcon.1) y y ex0 (ie.0) px0 (ip.0) timer 0 overflow 0x000b 1 tf0 (tcon.5) y y et0 (ie.1) pt0 (ip.1) external interrupt 1(int0 ) 0x0013 2 ie1 (tcon.3) y y ex1 (ie.2) px1 (ip.2) timer 1 overflow 0x001b 3 tf1 (tcon.7) y y et1 (ie.3) pt1 (ip.3) uart 0x0023 4 ri0 (scon0.0) ti0 (scon0.1) y n es0 (ie.4) ps0 (ip.4) timer 2 overflow 0x002b 5 tf2h (tmr2cn.7) tf2l (tmr2cn.6) y n et2 (ie.5) pt2 (ip.5) spi0 0x0033 6 spif (spi0cn.7) wcol (spi0cn.6) modf (spi0cn.5) rxovrn (spi0cn.4) y n espi0 (ie.6) pspi0 (ip.6) adc0 window compara- tor 0x003b 7 ad0wint (adc0cn.3) y n ewadc0 (eie1.0) pwadc0 (eip1.0) adc0 end of conversion 0x0043 8 ad0int (adc0cn.5) y n eadc0 (eie1.1) padc0 (eip1.1) programmable counter array 0x004b 9 cf (pca0cn.7) ccfn (pca0cn.n) y n epca0 (eie1.2) ppca0 (eip1.2) comparator falling ed ge 0x0053 10 cp0fif (cpt0cn.4) n n ecpf (eie1.3) pcpf (eip1.3) comparator rising edge 0x005b 11 cp0rif (cpt0cn.5) n n ecpr (eie1.4) pcpr (eip1.4) lin interrupt 0x0063 12 linint (linst.3) n n* elin (eie1.5) plin (eip1.5) voltage regulator dropout 0x006b 13 n/a n/a n/a ereg0 (eie1.6) preg0 (eip1.6) port match 0x0073 14 n/a n/a n/a emat (eie1.7) pmat (eip1.7) note: software must set the rstint bit (linctrl.3) to clear the linint flag.
c8051f52x/f53x 100 rev. 1.4 10.4. interrupt re gister descriptions the sfrs used to enable the interrupt sources and set t heir priority level are described below. refer to the data sheet section associated with a particular on-chi p peripheral for information regarding valid interrupt conditions for the peripheral and the behavior of its interrupt-pending flag(s). sfr definition 10.1. ie: interrupt enable bit7: ea : global interrupt enable. this bit globally enables/disabl es all interrupts. it overrides the individual interrupt mask set- tings. 0: disable all interrupt sources. 1: enable each interrupt accord ing to its individual mask setting. bit6: espi0 : enable serial peripheral interface (spi 0) interrupt. this bit sets the masking of the spi0 interrupts. 0: disable all spi0 interrupts. 1: enable interrupt requests generated by spi0. bit5: et2 : enable timer 2 interrupt. this bit sets the masking of the timer 2 interrupt. 0: disable timer 2 interrupt. 1: enable interrupt requests generated by the tf2l or tf2h flags. bit4: es0 : enable uart0 interrupt. this bit sets the masking of the uart0 interrupt. 0: disable uart0 interrupt. 1: enable ua rt0 interrupt. bit3: et1 : enable timer 1 interrupt. this bit sets the masking of the timer 1 interrupt. 0: disable all ti mer 1 interrupt. 1: enable interrupt requests generated by the tf1 flag. bit2: ex1 : enable external interrupt 1. this bit sets the masking of the external interrupt 1. 0: disable external interrupt 1. 1: enable extern interrupt 1 requests. bit1: et0 : enable timer 0 interrupt. this bit sets the masking of the timer 0 interrupt. 0: disable all ti mer 0 interrupt. 1: enable interrupt requests generated by the tf0 flag. bit0: ex0 : enable external interrupt 0. this bit sets the masking of the external interrupt 0. 0: disable external interrupt 0. 1: enable extern interrupt 0 requests. r/w r/w r/w r/w r/w r/w r/w r/w reset value ea espi0 et2 es0 et1 ex1 et0 ex0 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit addressable sfr address: 0xa8
rev. 1.4 101 c8051f52x/f53x sfr definition 10.2. ip: interrupt priority bit7: unused . read = 1b; write = don't care. bit6: pspi0 : serial peripheral interface ( spi0) interrupt priority control. this bit sets the priority of the spi0 interrupt. 0: spi0 interrupt set to low priority level. 1: spi0 interrupt set to high priority level. bit5: pt2 : timer 2 interrupt priority control. this bit sets the priority of the timer 2 interrupt. 0: timer 2 interrupt set to low priority level. 1: timer 2 interrupt set to high priority level. bit4: ps0 : uart0 interrupt priority control. this bit sets the priority of the uart0 interrupt. 0: uart0 interrupt set to low priority level. 1: uart0 interrupt set to high priority level. bit3: pt1 : timer 1 interrupt priority control. this bit sets the priority of the timer 1 interrupt. 0: timer 1 interrupt set to low priority level. 1: timer 1 interrupt set to high priority level. bit2: px1 : external interrupt 0 priority control. this bit sets the priority of the external interrupt 1. 0: int1 interr upt set to low priority level. 1: int1 interrup t set to high priority level. bit1: pt0 : timer 0 interrupt priority control. this bit sets the priority of the timer 0 interrupt. 0: timer 0 interrupt set to low priority level. 1: timer 0 interrupt set to high priority level. bit0: px0 : external interrupt 0 priority control. this bit sets the priority of the external interrupt 0. 0: int0 interr upt set to low priority level. 1: int0 interrup t set to high priority level. r r/w r/w r/w r/w r/w r/w r/w reset value - pspi0 pt2 ps0 pt1 px1 pt0 px0 10000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit addressable sfr address: 0xb8
c8051f52x/f53x 102 rev. 1.4 sfr definition 10.3. eie1: extended interrupt enable 1 bit7: emat : enable port match interrupt. this bit sets the masking of the port match interrupt. 0: disable the port match interrupt. 1: enable the port match interrupt. bit6: ereg0 : enable voltage regulator interrupt. this bit sets the masking of the voltage regulator dropout interrupt. 0: disable the voltage re gulator dropout interrupt. 1: enable the voltage regulator dropout interrupt. bit5: elin : enable lin interrupt. this bit sets the masking of the lin interrupt. 0: disable li n interrupts. 1: enable lin interrupt requests. bit4: ecpr : enable comparator 0 rising edge interrupt this bit sets the masking of the cp0 rising edge interrupt. 0: disable cp0 risin g edge interrupt. 1: enable cp0 rising edge interrupt. bit3: ecpf : enable comparator 0 falling edge interrupt this bit sets the masking of the cp0 falling edge interrupt. 0: disable cp0 falling edge interrupt. 1: enable cp0 falling edge interrupt. bit2: epca0 : enable programmable coun ter array (pca0) interrupt. this bit sets the masking of the pca0 interrupts. 0: disable all pc a0 interrupts. 1: enable interrupt requests generated by pca0. bit1: eadc0 : enable adc0 conversi on complete interrupt. this bit sets the masking of the adc0 conversion complete interrupt. 0: disable adc0 conver sion complete interrupt. 1: enable interrupt requests generated by the ad0int flag. bit0: ewadc0 : enable adc0 window comparison interrupt. this bit sets the masking of the adc0 window comparison interrupt. 0: disable adc0 window comparison interrupt. 1: enable interrupt requests generated by the ad0wint flag. r/w r/w r/w r/w r/w r/w r/w r/w reset value emat ereg0 elin ecpr ecpf epca0 eadc0 ewadc0 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: 0xe6
rev. 1.4 103 c8051f52x/f53x sfr definition 10.4. eip1: exte nded interrupt priority 1 bit7: pmat . port match interrup t priority control. this bit sets the priority of the port match interrupt. 0: port match interrupt se t to low priority level. 1: port match interrupt se t to high priority level. bit6: preg0 : voltage regulator interr upt priority control. this bit sets the priority of the voltage regulator interrupt. 0: voltage regulator interrup t set to low priority level. 1: voltage regulator interrupt set to high priority level. bit5: plin : lin interrupt priority control. this bit sets the priority of the cp0 interrupt. 0: lin interrupt set to low priority level. 1: lin interrupt set to high priority level. bit4: pcpr : comparator rising edge interrupt priority control. this bit sets the priority of the rising edge comparator interrupt. 0: comparator interrupt se t to low priority level. 1: comparator interrupt se t to high priority level. bit3: pcpf : comparator fallin g edge interrupt priority control. this bit sets the priority of th e falling edge comp arator interrupt. 0: comparator interrupt se t to low priority level. 1: comparator interrupt se t to high priority level. bit2: ppac0 : programmable counter array (pca0) interrupt priority control. this bit sets the priority of the pca0 interrupt. 0: pca0 interrupt set to low priority level. 1: pca0 interrupt set to high priority level. bit1: preg0 : adc0 conversion complete interrupt priority control. this bit sets the priority of the adc0 conversion complete interrupt. 0: adc0 conversion complete inte rrupt set to low priority level. 1: adc0 conversion complete inte rrupt set to high priority level. bit0: pwadc0 : adc0 window comparison interrupt priority control. this bit sets the priority of th e adc0 window comp arison interrupt. 0: adc0 window comparison inte rrupt set to low priority level. 1: adc0 window comparison interr upt set to high priority level. r/w r/w r/w r/w r/w r/w r/w r/w reset value pmat preg0 plin pcpr pcpf ppac0 preg0 pwadc0 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: 0xf6
c8051f52x/f53x 104 rev. 1.4 10.5. external interrupts the int0 and int0 external interrupt sources are configurable as active high or low, edge or level sensi- tive. the in0pl (int0 polarity) and in1pl (int0 polarity) bits in the it01cf register select active high or active low; the it0 and it1 bits in tcon (section ?18.1. timer 0 and timer 1? on page 182) select level or edge sensitive. the table below lis ts the possible configurations. int0 and int0 are assigned to port pins as defined in the it01cf register (see sfr definition 10.5). note that int0 and int0 port pin assignments are independent of any crossbar assignments. int0 and int0 will monitor their assigned port pins wit hout disturbing the peripheral that was assigned the port pin via the crossbar. to assign a port pin only to int0 and/or int0 , configure the crossbar to skip the selected pin(s). this is accomplished by setting the associated bit in register xbr0 (see section ?13.1. priority crossbar decoder? on page 122 for complete details on configuring the crossbar). in the typical configuration, the external interrupt pins should be skipped in the crossbar and configured as open-drain with the pin latch set to 1. see section ?13. port input/output? on page 120 for more informa- tion. ie0 (tcon.1) and ie1 (tcon.3) serve as the interrupt-pending flags for the int0 and int0 external inter- rupts, respectively. if an int0 or int0 external interrupt is configured as edge-sensitive, the corresponding interrupt-pending flag is automatically cleared by the hardware when the cpu ve ctors to the isr. when configured as level sensitive, the interrupt-pending flag remains logic 1 while the input is active as defined by the corresponding polarity bit (in0pl or in1pl); th e flag remains logic 0 while the input is inactive. the external interrupt source must hold the input active until the interrupt request is recognized. it must then deactivate the interrupt request befor e execution of the isr completes or another interrup t request will be generated. it0 in0pl int0 interrupt it1 in1pl int1 interrupt 1 0 active low, edge sensitive 1 0 active low, edge sensitive 1 1 active high, edge sensitive 1 1 active high, edge sensitive 0 0 active low, level sensitive 0 0 active low, level sensitive 0 1 active high, level sensitive 0 1 active high, level sensitive
rev. 1.4 105 c8051f52x/f53x sfr definition 10.5. it01cf : int0/int1 c onfiguration bit 7: in1pl : int0 polarity 0: int0 input is active low. 1: int0 input is active high. bits 6?4 : in1sl2?0 : int0 port pin selection bits these bits select which port pin is assigned to int0 . note that this pin assignment is inde- pendent of the crossbar; int0 will monitor the assigned port pin without disturbing the peripheral that has been assi gned the port pin via the cr ossbar. the crossbar will not assign the port pin to a peripheral if it is c onfigured to skip the selected pin (accomplished by setting to 1 the corresponding bit in register p0skip). bit 3: in0pl : int0 polarity 0: int0 interrupt is active low. 1: int0 interrupt is active high. bits 2?0 : int0sl2?0 : int0 port pin selection bits these bits select which port pin is assigned to int0 . note that this pin assignment is inde- pendent of the crossbar. int0 will monitor the assigned port pin without disturbing the peripheral that has been assi gned the port pin via the cr ossbar. the crossbar will not assign the port pin to a peripheral if it is c onfigured to skip the selected pin (accomplished by setting to 1 the corresponding bit in register p0skip). r/w r/w r/w r/w r/w r/w r/w r/w reset value in1pl in1sl2 in1sl1 in1sl0 in0pl in0sl2 in0sl1 in0sl0 00000001 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: 0xe4 note: refer to sfr definition 18.1. ?tcon: timer control? on page 186 for int0/1 edge- or level-sensitive interrupt selection. in1sl2-0 int1 port pin 000 p0.0 001 p0.1 010 p0.2 011 p0.3 100 p0.4 101 p0.5 110 p0.6* 111 p0.7* note: available in the c80151f53x/c8051f53xa parts. in0sl2-0 int0 port pin 000 p0.0 001 p0.1 010 p0.2 011 p0.3 100 p0.4 101 p0.5 110 p0.6* 111 p0.7* note: available in the c80151f53x/c8051f53xa parts.
c8051f52x/f53x 106 rev. 1.4 11. reset sources reset circuitry allows the controller to be easily placed in a predefined default condition. on entry to this reset state, th e following occur: ? cip-51 halts program execution ? special function registers (sfrs) are initialized to their defined reset values ? external port pins are forced to a known state ? interrupts and timers are disabled. all sfrs are reset to the predefined values noted in the sfr detailed descriptions. the contents of internal data memory are unaffected during a reset; any prev iously stored data is preserved. however, since the stack pointer sfr is reset, the stack is effectively lo st, even though the data on the stack is not altered. the port i/o latches are reset to 0xff (all logic ones) in open-drain mode. weak pullups are enabled dur- ing and after the reset. for v dd monitor and power-on resets, the rst pin is driven low until the device exits the reset state. on exit from the reset state, the program counter (pc) is reset, and the system clock defaults to the inter- nal oscillator. refer to section ?14. oscillators? on page 13 5 for information on se lecting and configuring the system clock source. the watchdog timer is enabled with the system clock divided by 12 as its clock source (section ?19.3. watchdog timer mode? on page 203 details the use of the watchdog timer). pro- gram execution begins at location 0x0000. figure 11.1. reset sources pca wdt missing clock detector (one- shot) (software reset) system reset reset funnel px.x px.x en swrsf system clock cip-51 microcontroller core extended interrupt handler en wdt enable mcd enable illegal flash operation /rst (wired-or) power on reset '0' + - comparator 0 vdd + - supply monitor (vddmon0) enable c0rsef + - (wired-or) supply monitor (vddmon1) enable
rev. 1.4 107 c8051f52x/f53x 11.1. power-on reset during power-up, the device is held in a reset state and the rst pin is driven low until v dd settles above v rst . v dd ramp time is defined as how fast v dd ramps from 0 v to v rst . an additional delay (t pordelay ) occurs before the device is released from reset. the v rst threshold and t pordelay are specified in table 2.8, ?reset electrical characteristics,? on page 32. figure 11.2 plots the power-on and v dd monitor reset timing. note: please refer to section ?20.4. vdd monitors and vdd ramp time? on page 211 for definition of v rst and v dd ramp time in older silicon revisions a and b. ? on exit from a power-on reset, the porsf flag (rstsr c.1) is set by hardware to logic 1. when porsf is set, all of the other reset flags in the rstsrc regist er are indeterminate (porsf is cleared by all other resets). since all resets cause program execution to begin at the same location (0x0000), software can read the porsf flag to determine if a power-up was the cause of reset. the contents of internal data memory should be assumed to be undefined after a power-on reset. both the v dd monitors (vddmon0 and vddmon1) are enabled following a power-on reset. note: please refer to section ?11.2.1. vdd monitor thresholds and minimum vdd? on page 108 for recommendations related to minimum v dd . ? figure 11.2. power-on and v dd monitor reset timing power-on reset vdd monitor reset /rst t volts 1.0 logic high logic low t pordelay v d d v rst vdd
c8051f52x/f53x 108 rev. 1.4 11.2. power-fail reset / v dd monitors (vddmo n0 and vddmon1) c8051f52x-c/f53x-c devices include two v dd monitors: a standard v dd monitor (vddmon0) and a level-sensitive v dd monitor (vddmon1). vddmon0 is primarily intended for setting a higher threshold to allow safe erase or write of flash memory from firm ware. vddmon1 is used to ho ld the device in a reset state during power-up and brownout conditions. note: vddmon1 is not present in older silicon revisions a and b. please refer to section ?20.4. vdd monitors and vdd ramp time? on page 211 for more details. ? when a power-down transition or power irregularity causes v dd to drop below v rst , the power supply monitors (vddmon0 and vd dmon1) will drive the rst pin low and hold the cip-51 in a reset state (see figure 11.2). when v dd returns to a level above v rst , the cip-51 will be released from the reset state. note that even though internal data memory contents are not altered by the power-fail reset, it is impossi- ble to determine if v dd dropped below the level required for data retention. if the porsf flag reads 1, the data may no longer be valid. vddmon0 is enabled and is selected as a reset source after power-on resets; however its defined state (enabled/disabled) is not altered by any other reset so urce. for example, if vddm on0 is disabled by soft- ware, and a software reset is performed, vddmon0 will still be disabled after that reset. vddmon1 is enabled and is selected as a reset source after power-on reset and any other type of reset. there is no register setting that can disable th is level-sensitive vdd mo nitor as a reset source. to protect the integrity of flash contents, the v dd monitor (vddmon0) must be enabled to the higher setting (vdmlvl = '1') and selected as a reset source if software contains routines which erase or write flash memory. if the v dd monitor is not enabled and set to the higher setting, any erase or write performed on flash memory will cause a flash error device reset. note: please refer to section ?20.5. vdd monitor (vddmon0) high threshold setting? on page 212 for important notes related to the vdd monitor high threshold setting in older silicon revisions a and b. ? the v dd monitor (vddmon0) must be enabled before it is selected as a reset source. selecting the vddmon0 as a reset source before it is enabled and stabilized may cause a system reset. the procedure for re-enabling the v dd monitor and configuring the v dd monitor as a reset source is shown below: 1. enable the v dd monitor (vdmen bit in vddmon = 1). 2. wait for the v dd monitor to stabilize (see tabl e 2.8 on page 32 for the v dd monitor turn-on time). note: this delay should be omitted if software contains routines which write or erase flash memory. 3. select the v dd monitor as a reset source (porsf bit in rstsrc = 1). see figure 11.2 for v dd monitor timing; note that the reset delay is not incurred after a v dd monitor reset. see table 2.8 on page 32 for complete electrical characteristics of the v dd monitor. note: software should take care not to inadvertently disable the v dd monitor (vddmon0) as a reset source when writing to rstsrc to enable other reset sources or to trigger a software reset. all writes to rstsrc should explicitly set porsf to '1' to keep the v dd monitor enabled as a reset source. ? 11.2.1. vdd monitor thresholds and minimum vdd the minimum operating digital supply voltage (v dd ) is specified as 2.0 v in table 2.2 on page 26. the volt- age at which the mcu is released from reset (v rst ) can be as low as 1.65 v based on the v dd monitor thresholds that are specified in table 2.8 on page 32. this could allow code execution during the power-up
rev. 1.4 109 c8051f52x/f53x ramp or during a brownout condition even when v dd is below the specified minimum of 2.0 v. there are two possible ways to handle this transitional period as described below: if using the on-chip regulator (reg0) at the 2.6 v setti ng (default), it is recommended that user software set the vddmon0 threshold to its high setting (v rst-high ) as soon as possible after reset by setting the vdmlvl bit to 1 in sfr definition 11.1 (vddmon). in this typical configuration, no external hardware or additional software routines are necessary to monitor the v dd level. note: please refer to section ?20.5. vdd monitor (vddmon0) high threshold setting? on page 212 for important notes related to the vdd monitor high threshold setting in older silicon revisions a and b. ? if using the on-chip regulator (reg0) at t he 2.1 v setting or if directly driving v dd with reg0 disabled, the user system (software/hardware) should monitor v dd at power-on and also du ring device operation. the two key parameters that can be affected when v dd < 2.0 v are: internal oscilla tor frequency (table 2.11 on page 34) and minimum adc tracking time (table 2.3 on page 28). sfr definition 11.1. vddmon: v dd monitor control bit7 : vdmen : v dd monitor enable (vddmon0). this bit turns the v dd monitor circuit on/off. the v dd monitor cannot generate system resets until it is also selected as a reset sour ce in register rstsrc (sfr definition 11.2). the v dd monitor can be allowed to stabilize before it is sele cted as a reset source. select- ing the v dd monitor as a reset source before it has stabilized may generate a system reset. see table 2.8 on page 32 for the minimum v dd monitor turn-on time. 0: v dd monitor disabled. ? 1: v dd monitor enabled (default). bit6 : vddstat : v dd status. this bit indicates the current power supply status (v dd monitor output). 0: v dd is at or below the v dd monitor (vddmon0) threshold. 1: v dd is above the v dd monitor (vddmon0) threshold. bit5 : vdmlvl : v dd level select. 0: v dd monitor (vddmon0) threshold is set to v rst-low (default). 1: v dd monitor (vddmon0) threshold is set to v rst-high . this setting is required for any system that includes code that writes to and/or erases flash. bit4 : vdm1en * : level-sensitive v dd monitor enable (vddmon1). this bit turns the v dd monitor circuit on/off. if turned on, it is also selected as a reset source, and can generate a system reset. 0: level-sensitive vdd monitor disabled. 1: level-sensitive vdd monitor enabled (default). bits3?0 : reserved . read = variable. write = don?t care. *note: available only on the c8051f52x-c/f53x-c devices r/w r r/w r r r r r reset value vdmen vddstat vdmlvl vdm1en reserved reserved reserved reserved 1v010000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: 0xff
c8051f52x/f53x 110 rev. 1.4 11.3. external reset the external rst pin provides a means for external circuitry to force the device into a reset state. assert- ing an active-low signal on the rst pin generates a reset; an external pullup and/or decoupling of the rst pin may be necessary to avoid erroneous noise-induced resets. see table 2.8 on page 32 for complete rst pin specifications. the pinrsf flag (rstsrc.0) is set on exit from an external reset. note: please refer to section ?20.6. reset low time? on page 212 for restrictions on reset low time in older silicon revisions a and b. ? 11.4. missing clock detector reset the missing clock detector (mcd) is a one-shot circuit that is triggered by the syst em clock. if the system clock remains high or low for more than 100 s, the one-sho t will time out and genera te a reset. after a mcd reset, the mcdrsf flag (rstsrc.2) will read 1, signifying the mcd as the reset source; otherwise, this bit reads 0. writing a 1 to the mcdrsf bit enables the missing clock detector; writing a 0 disables it. the state of the rst pin is unaffected by this reset. 11.5. comparator reset comparator0 can be configured as a reset source by writing a 1 to the c0rsef flag (rstsrc.5). comparator0 should be enabled and allowed to settle prior to writing to c0rsef to prevent any turn-on chatter on the output from generating an unwanted rese t. the comparator0 reset is active-low: if the non- inverting input voltage (on cp0+) is le ss than the inverting input voltage (on cp0-), the device is put into the reset state. after a compar ator0 reset, the c0rsef flag (rst src.5) will read 1 signifying comparator0 as the reset source; otherwise, this bit reads 0. the state of the rst pin is unaffected by this reset. 11.6. pca watchdog timer reset the programmable watchdog timer (wdt) function of the programmable counter array (pca) can be used to prevent software from running out of cont rol during a system malfunction. the pca wdt function can be enabled or disabled by software as desc ribed in section ?19.3. watchdog timer mode? on page 203; the wdt is enabled and clocked by sysclk / 12 following any reset. if a system malfunction prevents user software from updating the wdt, a re set is generated and the wdtrsf bit (rstsrc.5) is set to 1. the state of the rst pin is unaffected by this reset. 11.7. flash error reset if a flash read/write/era se or program read targets an illegal address, a system reset is generated. this may occur due to any of the following: ? a flash write or erase is attempted above user code space. this occurs when pswe is set to 1 and a movx write operation targets an address above the lock byte address. ? a flash read is attempted above user code space. this occurs when a movc operation targets an address above the lock byte address. ? a program read is attempted above user code space. this occurs when user code attempts to branch to an address above the lock byte address. ? a flash read, write or erase attempt is restrict ed due to a flash security setting (see section ?12.4. security options? on page 117). ? a flash write or erase is attempted while the v dd monitor (vddmon0) is disabled or not set to its high threshold setting. the ferror bit (rstsrc.6) is set following a flash error reset. the state of the rst pin is unaffected by this reset.
rev. 1.4 111 c8051f52x/f53x 11.8. software reset software may force a reset by wr iting a 1 to the swrsf bit (rstsr c.4). the swrsf bit will read 1 fol- lowing a software forced reset. the state of the rst pin is unaffected by this reset.
c8051f52x/f53x 112 rev. 1.4 sfr definition 11.2. rstsrc: reset source note: software should avoid read modify write in structions when writing values to rstsrc. bit7: unused . read = 1, write = don't care. bit6: ferror : flash error indicator. 0: source of last reset was not a flash read/write/erase error. 1: source of last reset was a flash read/write/erase error. bit5: c0rsef : comparator0 reset enable and flag. 0: read: source of last reset was not comparator0. write: comparator0 is not a reset source. 1: read: source of last reset was comparator0. write: comparator0 is a reset source (active-low). bit4: swrsf : software reset force and flag. 0: read: source of last reset was not a write to the swrsf bit. write: no effect. 1: read: source of last reset was a write to the swrsf bit. write: forces a system reset. bit3: wdtrsf : watchdog timer reset flag. 0: source of last reset was not a wdt timeout. 1: source of last reset was a wdt timeout. bit2: mcdrsf : missing clock detector flag. 0: read: source of last reset was not a missing clock detector timeout. write: missing clock detector disabled. 1: read: source of last reset was a mi ssing clock detector timeout. write: missing clock detector enab led; triggers a rese t if a missing clock condition is detected. bit1: porsf : power-on reset force and flag. this bit is set anytime a power-on reset occurs. writing this bit enables/disables the v dd monitor (vddmon0) as a reset source. note: writing 1 to this bit before the v dd moni- tor is enabled and stabilized may cause a system reset. see register vddmon (sfr definition 11.1) 0: read: last reset was not a power-on or v dd monitor reset. write: v dd monitor (vddmon0) is not a reset source. 1: read: last reset was a power-on or v dd monitor reset; all other reset flags indetermi- nate. write: v dd monitor (vddmon0) is a reset source. bit0: pinrsf : hw pin reset flag. 0: source of last reset was not rst pin. 1: source of la st reset was rst pin. r/w r r/w r/w r r/w r/w r reset value ? ferror c0rsef swrsf wdtrsf mcdrsf porsf pinrsf variable bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: 0xef
rev. 1.4 113 c8051f52x/f53x 12. flash memory on-chip, re-programmable flash memory is included fo r program code and non-volatile data storage. the flash memory can be programmed in-system through the c2 interface or by software using the movx write instruction. once cleared to logic 0, a flash bit mu st be erased to set it back to logic 1. flash bytes would typically be erased (set to 0xff) before be ing reprogrammed. the write and erase operations are automatically timed by hard ware for proper execution; data polling to determine the end of th e write/erase operations is not required. code execution is sta lled during flash write/erase operations. refer to table 2.9 on page 33 for complete fl ash memory electrical characteristics. 12.1. programming the flash memory the simplest means of programming the flash memory is through the c2 interface using programming tools provided by silicon laboratories or a th ird party vendor. this is the only means for programming a non-initialized device. fo r details on the c2 commands to program flash memory, see section ?21. c2 interface? on page 214. to protect the integrity of flash contents, the v dd monitor must be enabled to the higher setting (vdmlvl = '1') and selected as a reset source if software contains routines which erase or write flash memory. if the v dd monitor is not enab led, any erase or wr ite performed on flash memory will cause a flash error device reset. see section ?11.2. power-fail reset / vdd monitors (vddmon0 and vddmon1)? on page 108 for more information regard ing the vdd monitor and the high threshold setting. the v dd monitor must be enabled before it is selected as a reset source. selecting the v dd monitor as a reset source before it is enabled and stabilized may cause a system reset. the procedure for re- enabling the v dd monitor and configuring the v dd monitor as a reset so urce is shown below: 1. enable the v dd monitor (vdmen bit in vddmon = 1). 2. wait for the v dd monitor to stabilize (see tabl e 2.8 on page 32 for the v dd monitor turn-on time). note: this delay should be omitted if software contains routines which write or erase flash memory. 3. select the v dd monitor as a reset source (porsf bit in rstsrc = 1). note: 8-bit movx instructions cannot be used to erase or write to flash memory at addresses higher than 0x00ff. important note: for ?i (industrial grade) parts, flash should be programmed (erase/write) at a mini- mum temperature of 0 c for reliable flash operation across the entire temperature range of ?40 to +125 c. this minimum programming temperature doe s not apply to ?a (automotive grade) parts. 12.1.1. flash lock and key functions flash writes and erases by user so ftware are protected with a lock and key function. the flash lock and key register (flkey) must be writ ten with the correct key codes, in sequence, be fore flash operations may be performed. the key codes are: 0xa5, 0xf1. the timing does not matter, but the codes must be written in order. if the key codes are written out of or der, or the wrong codes are written, flash writes and erases will be disabled until the next system reset. flash writes and eras es will also be disabled if a flash write or erase is attempted before the key codes have been written properly. the flash lock resets after each write or erase; the key codes must be writte n again before a following flash operation can be per- formed. the flkey register is det ailed in sfr definition 12.2.
c8051f52x/f53x 114 rev. 1.4 12.1.2. flash erase procedure the flash memory can be programmed by software using the movx write instru ction with the address and data byte to be programmed provided as normal ope rands. before writing to flash memory using movx, flash write operations must be enabled by: (1) setting the pswe program store write enable bit (psctl.0) to logic 1 (this directs the movx writes to target flash memory); and (2) writing the flash key codes in sequence to the flash lock register (flkey). the pswe bit remains set until cleared by soft- ware. a write to flash memory can clear bits to logic 0 but cannot set them; only an erase operation can set bits to logic 1 in flash. a byte location to be programmed should be erased before a new value is written. the flash memory is organized in 512-byte pages. the erase operation applies to an entire page (setting all bytes in the page to 0xff). to erase an en tire 512-byte page, perform the following steps: 1. disable interrupts (recommended). 2. write the first key code to flkey: 0xa5. 3. write the second key code to flkey: 0xf1. 4. set the psee bit (register psctl). 5. set the pswe bit (register psctl). 6. using the movx instruction, write a data byte to any location within the 512-byte page to be erased. 7. clear the pswe and psee bits. 8. re-enable interrupts. 12.1.3. flash write procedure flash bytes are programmed by software with the following sequence: 1. disable interrupts. 2. write the first key code to flkey: 0xa5. 3. write the second key code to flkey: 0xf1. 4. set the pswe bit (register psctl). 5. clear the psee bit (register psctl). 6. using the movx instruction, write a single data byte to the desired location within the 512-byte sector. 7. clear the pswe bit. 8. re-enable interrupts. steps 2?7 must be repeated for each byte to be written. after flash writes are complete, pswe should be cleared so that movx instructions do not target program memory.
rev. 1.4 115 c8051f52x/f53x 12.2. flash write and erase guidelines any system which contains routines which write or er ase flash memory from software involves some risk that the write or erase ro utines will execute unin tentionally if the cpu is op erating outside its specified operating range of v dd , system clock frequency, or temperature. this accidental execution of flash modi- fying code can result in alteration of flash memory contents causing a system failure that is only recover- able by re-flashing the code in the device. the following guidelines are recommended for any syst em which contains routin es which write or erase flash from code. 12.2.1. v dd maintenance and the v dd monitor 1. if the system power supply is subject to voltage or current "spikes," add sufficient transient protection devices to the power supply to ensure that the supply voltages listed in the absolute maximum ratings table are not exceeded. 2. make certain that the maximum v dd ramp time specification (if applicable) is met. see section 20.4 on page 211 for more details on v dd ramp time. if the system cannot m eet this ramp time specification, then add an external v dd brownout circuit to the rst pin of the device that holds the device in reset until v dd reaches the minimum specified v dd and re-asserts rst if v dd drops belowthat level. v dd (min) is specified in table 2.2 on page 26. 3. enable the on-chip v dd monitor (vddmon0) and enable it as a reset source as early in code as possible. this should be the first set of instructio ns executed after the reset vector. for c-based systems, this will involve modifyin g the startup code a dded by the c compiler. see your compiler documentation for more details. make certain that th ere are no delays in software between enabling the v dd monitor (vddmon0) and enabling it as a reset source. code examples showing this can be found in ?an201: writing to flash from firmware", av ailable from the silicon laboratories web site. 4. as an added precaution , explicitly enable the v dd monitor (vddmon0) and enable the v dd monitor as a reset source inside the functions that write and erase flash memory. the v dd monitor enable instructions should be placed just after the instruction to set pswe to a 1, but before the flash write or erase operation instruction. 5. make certain that all writes to the rstsrc (reset sources) register use di rect assignment operators and explicitly do not use the bit-wise operators (such as and or or). for example, "rstsrc = 0x02" is correct. "rstsrc |= 0x02" is incorrect. 6. make certain that all writes to the rstsrc register explicitly set the porsf bi t to a 1. areas to check are initialization code which enables other reset sources, such as the missing clock detector or comparator, for example, and instructions which force a software reset. a global search on "rstsrc" can quickly verify this. 12.2.2. pswe maintenance 1. reduce the number of places in code where the pswe bit (psctl.0) is set to a 1. there should be exactly one routine in code that sets pswe to a 1 to write flash bytes and one routine in code that sets pswe and psee both to a 1 to erase flash pages. 2. minimize the number of variable accesses while pswe is set to a 1. handle pointer address updates and loop variable maintenance outside the "pswe = 1;... pswe = 0;" area. code examples showing this can be found in ?an201: writing to flash from firmware, " available from the silicon laboratories web site. 3. disable interrupts prior to setting pswe to a 1 and leave them disabled until after pswe has been reset to '0'. any interrupt s posted during the flash write or eras e operation will be serviced in priority order after the flash operation has been completed a nd interrupts have been re-enabled by software. 4. make certain that the flash write and erase poin ter variables are not located in xram. see your compiler documentation for instructions regarding how to explicitly locate variab les in different memory areas.
c8051f52x/f53x 116 rev. 1.4 5. add address bounds checking to th e routines that write or erase flas h memory to ensure that a routine called with an illegal address does not result in modification of the flash. 12.2.3. system clock 1. if operating from an external crystal, be advised th at crystal performance is susceptible to electrical interference and is sensitive to layout and to changes in temperature. if the system is operating in an electrically noisy environment, use the internal oscillator or use an external cmos clock. 2. if operating from the external oscillator, switch to the internal oscillator du ring flash write or erase operations. the external oscillator can continue to run, and the cpu can switch back to the external oscillator after the flash operation has completed. ? additional flash recommendations and example code can be found in application note ? an201: writing to flash from firmware, " available from the silic on laboratories website.
rev. 1.4 117 c8051f52x/f53x 12.3. non-volati le data storage the flash memory can be used for non-volatile data storage as well as program code. this allows data such as calibration coefficients to be calculated and stored at run time. data is written using the movx write instruction and read using the movc instructi on. note: movx read instructions always target xram. note : see section ?12.1. programming the flash memory? on page 113 for minimum v dd and tempera- ture requirements for flash erase and write operations. 12.4. security options the cip-51 provides security options to protect the flash memory from inadvertent modification by soft- ware as well as to prevent the viewing of proprietary program code and constants. the program store write enable (bit pswe in register psctl) and the program store erase enable (bit psee in register psctl) bits protect the flash memory from accidental modification by software. pswe must be explicitly set to 1 before software can modify the flash memory; both pswe and psee must be set to 1 before soft- ware can erase flash memory. additional security features prevent proprietary program code and data constants from being read or altered across the c2 interface. a security lock byte located at the last byte of fl ash user space offers protection of the flash program memory from access (reads, writes, or erases) by unpr otected code or the c2 inte rface. the flash security mechanism allows the user to lock n 512-byte flash pages, starting at page 0 (addresses 0x0000 to 0x01ff), where n is the 1?s complement number represented by the security lock byte. note that the page containing the flash security lock byte is unlocked when no other flash pages are locked (all bits of the lock byte are 1) and locked when any other flash pages are locked (any bit of the lock byte is 0). see example below. figure 12.1. flash program memory map security lock byte: 11111101b 1?s complement: 00000010b flash pages locked: 3 (first two flash pages + lock byte page) addresses locked: 0x0000 to 0x03ff (first two flash pages) ? 0x1c00 to 0x1dff in ?f520/0a/1/1a and ?f530/0a/1/1a ? 0x0c00 to 0x0fff in ?f523/3a/4/4a and ?f533/3a/4/4a and ? 0x0600 to 0x07ff in ?f526/6a/7/7a and ?f536/6a/7/7a access limit set according to the flash security lock byte 0x0000 0x0fff lock byte reserved 0x0ffe flash memory organized in 512-byte pages 0x0e00 unlocked flash pages locked when any other flash pages are locked 0x0000 0x1dfe 0x1e00 0x1c00 'f520/0a/1/1a and 'f530/0a/1/1a 'f523/3a/4/4a and 'f533/3a/4/4a lock byte reserved unlocked flash pages 0x0000 0x07ff lock byte reserved unlocked flash pages 0x1dff 'f526/6a/7/7a and 'f536/6a/7/7a 0x07fe 0x0600
c8051f52x/f53x 118 rev. 1.4 the level of flash security depends on the flash ac cess method. the three flash access methods that can be restricted are reads, writes, an d erases from the c2 debug interface, user firmware executing on unlocked pages, and user firmware executing on locked pages. table 12.1 summarizes the flash security features of the ?f52x/?f52xa/?f53x/?f53xa devices. table 12.1. flash security summary action c2 debug interface user firmware executing from: an unlocked page a locked page read, write or erase unlocked pages (except page with lock byte) permitted permitted permitted read, write or erase locked pages (except page with lock byte) not permitted flash error reset permitted read or write page containing lock byte (if no pages are locked) permitted permitted permitted read or write page containing lock byte (if any page is locked) not permitted flash error reset permitted read contents of lock byte (if no pages are locked) permitted permitted permitted read contents of lock byte (if any page is locked) not permitted flash error reset permitted erase page containing lock byte (if no pages are locked) permitted flash error re set flash error reset erase page containing lock byte?unlock all pages (if any page is locked) c2 device erase only flash error reset flash error reset lock additional pages (change 1s to 0s in the lock byte) not permitted flash error reset flash error reset unlock individual pages (change 0s to 1s in the lock byte) not permitted flash error reset flash error reset read, write or erase reserved area not perm itted flash error rese t flash error reset ? c2 device erase?erases all flash pages in cluding the page containing the lock byte. flash error reset?not permitted; ca uses flash error device reset (ferror bit in rstsrc is 1 after reset). ? - all prohibited operations that are performed via the c2 interface are ignored (do not cause device reset). - locking any flash page also locks th e page containing the lock byte. - once written to, the lock byte cannot be modifi ed except by performing a c2 device erase. - if user code writes to the lock byte, the lock does not take effect until the next device reset.
rev. 1.4 119 c8051f52x/f53x sfr definition 12.1. psctl: program store r/w control sfr definition 12.2. flk ey: flash lock and key bits7?2 : unused : read = 000000b, write = don?t care. bit1 : psee : program store erase enable setting this bit (in combination with pswe) a llows an entire page of flash program memory to be erased. if this bit is logic 1 and flash writes are enabled (pswe is logic 1), a write to flash memory using the movx in struction will erase the entire page that contains the loca- tion addressed by the movx instruction. the va lue of the data byte written does not matter. 0: flash program memory erasure disabled. 1: flash program memory erasure enabled. bit0 : pswe : program store write enable setting this bit allows writing a byte of data to the flash program memory using the movx write instruction. the flash location should be erased before writing data. 0: writes to flash program memory disabled. 1: writes to flash program memory enabled; the movx write instruction targets flash memory. note : see section ?12.1. programming the fl ash memory? on page 113 for minimum v dd and temperature requirements for flash erase and write operations. rrrrrrr / wr / wr e s e t v a l u e ? ? ? ? ? ? psee pswe 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: 0x8f bits7?0 : flkey : flash lock and key register write: this register provides a lock and key function for flash erasures and writes. flash writes and erases are enabled by writing 0xa5 fo llowed by 0xf1 to th e flkey register. flash writes and erases are aut omatically disabled after the next write or erase is complete. if any writes to flkey are performed inco rrectly, or if a flash write or erase ope ration is attempted while these operations are dis abled, the flash will be permanently locked fr om writes or era- sures until the next device reset. if an applicat ion never writes to flash, it can intentionally lock the flash by writing a non-0xa5 value to flkey from software. read: when read, bits 1 ? 0 indicate the current flash lock state. 00: flash is write/erase locked. 01: the first key code has been written (0xa5). 10: flash is unlocked (w rites/erases allowed). 11: flash writes/erases disa bled until the next reset. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: 0xb7
c8051f52x/f53x 120 rev. 1.4 13. port input/output digital and analog resources are available through up to 16 i/o pins. port pins are organized as two or one byte-wide ports. each of the port pins can be defin ed as general-purpose i/o (gpio) or analog input/out- put; port pins p0.0 - p2.7 can be assigned to one of the internal digital resources as shown in figure 13.3. the designer has complete control over which function s are assigned, limited only by the number of phys- ical i/o pins. this resource assign ment flexibility is achieved throug h the use of a priority crossbar decoder. note that the state of a port i/o pin can always be read in the corresponding port latch, regard- less of the crossbar settings. the crossbar assigns the selected internal digital res ources to the i/o pins based on the peripheral priority order of the priority decoder (figure 13.3 and figure 13.4). the registers xbr0 and xbr1, defined in sfr definition 13.1 and sfr definition 13.2, are used to select internal digital functions. port i/o pins are 5.25 v tolerant over the operating range of v regin . figure 13.2 shows the port cell circuit. the port i/o cells are configured as either push-pull or open-drain in the port output mode registers (pnmdout, where n = 0,1). complete electrical specif ications for port i/o are given in table 2.10 on page 33. figure 13.1. port i/o functional block diagram xbr0, xbr1, pnskip registers digital crossbar priority decoder 2 p0 i/o cells p0.0 p0.7 8 p0mask, p0match p1mask, p1match registers uart (internal digital signals) highest priority lowest priority sysclk t0, t1 2 7 pca 2 cp0 outputs spi 4 p1 i/o cells p1.0 p1.7 8 (port latches) p0 (p0.0-p0.7) (p1.0-p1.7*) 8 8 p1 pnmdout, pnmdin registers p1.0?1.7 and p0.7 available on c8051f53x/ c8051f53xa parts lin 2
rev. 1.4 121 c8051f52x/f53x figure 13.2. port i/o cell block diagram gnd /port-outenable port-output push-pull vregin vregin /weak-pullup (weak) port pad analog input analog select port-input
c8051f52x/f53x 122 rev. 1.4 13.1. priority crossbar decoder the priority crossbar decoder (figure 13.3) assigns a priority to each i/o function, starting at the top with uart0. when a digital resource is selected, the leas t-significant unassigned port pin is assigned to that resource (excluding uart0, which will be assigned to pins p0.4 and p0.5). if a port pin is assigned, the crossbar skips that pin when assign ing the next selected reso urce. additionally, the cr ossbar will skip port pins whose associated bits in the pnskip registers are set. the pnskip registers allow software to skip port pins that are to be used for analog input, dedicated functions, or gpio. figure 13.3. crossbar priority decoder with no pins skipped (tssop 20 and qfn 20) important note on crossbar configuration : if a port pin is claimed by a peripheral without use of the crossbar, its corresponding pnskip bit should be set. this applies to p1.0 and/or p0.7 (f53x/f53xa) or p0.2 and/or p0.3 (f52x/ f52xa) for the external oscillator, p0.0 for v ref , p1.2 (f53x/f53xa) or p0.5 note: 4-wire spi only. 0123456701234567 sck miso lin-tx lin_rx cp0 cp0a /sysclk cex0 cex1 cex2 eci t0 t1 0000000000000000 port pin potentially assignable to peripheral special function signals are not assigned by the crossbar. when these signals are enabled, the crossbar must be manually configured to skip their corresponding port pins. sf signals cnvstr vref p0skip[0:7] nss* mosi xtal1 sf signals pin i/o tssop 20 and qfn 20 p0 p1 p1skip[0:7] xtal2 rx0 tx0 rx0 c8051f53xa/f53x-c devices c8051f53x devices tx0
rev. 1.4 123 c8051f52x/f53x (f52x/f52xa) for the external cnvstr signal, and any selected adc or comparator inputs. the crossbar skips selected pins as if they were already assigned, and moves to t he next unassigned pin. figure 13.3 shows the crossbar decoder priority with no port pins skipped (p0skip, p1skip); figure 13.4 shows the crossbar decoder priority with the xtal1 (p1.0) and xtal2 (p1.1) pins skipped (p1skip = 0x03). important note on uart pins : on c8051f52xa/f52x-c/f53xa/f53x-c devices, the uart pins must be skipped if the uart is enabled in order for peripherals to appear on port pins beyond the uart on the crossbar. for example, with the spi and uart enable d on the crossbar with the spi on p1.0-p1.3, the uart pins must be skipped using p0skip for the spi pins to appear correctly. figure 13.4. crossbar priority decoder with crystal pins skipped (tssop 20 and qfn 20) note: 4-wire spi only. 0123456701234567 cp0 cp0a /sysclk cex0 cex1 cex2 eci t0 t1 0000000110000000 port pin potentially assignable to peripheral special function signals are not assigned by the crossbar. when these signals are enabled, the crossbar must be manually configured to skip their corresponding port pins. sf signals nss* p1 tssop 20 and qfn 20 sck tx0 pin i/o p0 rx0 lin-tx p0skip[0:7] = 0x80 p1skip[0:7] = 0x01 miso mosi lin-rx sf signals vref xtal1 xtal2 rx0 c8051f53x devices c8051f53xa/f53x-c devices tx0 cnvstr
c8051f52x/f53x 124 rev. 1.4 figure 13.5. crossbar priority decoder with no pins skipped (dfn 10) note: 4-wire spi only. 012345 sck miso lin-tx lin_rx cp0 cp0a /sysclk cex0 cex1 cex2 eci t0 t1 000000 port pin potentially assignable to peripheral special function signals are not assigned by the crossbar. when these signals are enabled, the crossbar must be manually configured to skip their corresponding port pins. tx0 nss* mosi c8051f52xa/f52x-c devices c8051f52x devices sf signals rx0 pin i/o sf signals dfn10 tx0 rx0 p0skip[0:5] vref xtal1 xtal2 cnvstr
rev. 1.4 125 c8051f52x/f53x figure 13.6. crossbar priority decoder with some pins skipped (dfn 10) registers xbr0 and xbr1 are used to assign the digital i/o resources to the physical i/o port pins. note that when the smbus is selected, the crossbar assi gns both pins associated with the smbus (sda and scl); when the uart is selected, the crossbar assign s both pins associated with the uart (tx and rx). uart0 pin assignments are fixed for bootloading pur poses: uart tx0 is always assigned to p0.3 or p0.4*; uart rx0 is always assigned to p0.4 or p0.5*. standard port i/os appear contiguously starting at p0.0 after prioritized functions and skipped pins are assigned. note: refer to section ?20. device specific behavior? on page 210. note: 4-wire spi only. 012345 cp0 cp0a /sysclk cex0 cex1 cex2 eci t0 t1 011000 port pin potentially assignable to peripheral special function signals are not assigned by the crossbar. when these signals are enabled, the crossbar must be manually configured to skip their corresponding port pins. c8051f52xa/f52x-c devices p0skip[0:5] = 0x06 lin-tx mosi c8051f52x devices rx0 xtal2 tx0 miso cnvstr p0 vref xtal1 sf signals nss* sck tx0 lin-rx sf signals dfn 10 pin i/o rx0
c8051f52x/f53x 126 rev. 1.4 important note: the spi can be operated in either 3-wire or 4-wire modes, depending on the state of the nssmd1 ? nssmd0 bits in register spi0cn. according to the spi mode, the nss signal may or may not be routed to a port pin. 13.2. port i/o initialization port i/o initialization cons ists of the following steps: 1. select the input mode (analog or digital) for all port pins, using the port input mode register (pnmdin). 2. select the output mode (open-drain or push-pull) fo r all port pins, using the port output mode register (pnmdout). 3. select any pins to be skipped by the i/o cr ossbar using the port skip registers (pnskip). 4. assign port pins to desired peripherals using the xbrn registers. 5. enable the cro ssbar (xbare = 1). all port pins must be configured as either analog or digital inputs. any pins to be used as comparator or adc inputs should be configured as an analog inputs. when a pin is configured as an analog input, its weak pullup, digital driver, and digital receiver are disabled. this process save s power and reduces noise on the analog input. pins configured as digital inputs may still be used by analog peripherals; however, this practice is not recommended. additionally, all analog input pins should be configur ed to be skipped by the crossbar (accomplished by setting the associated bits in pnskip). port input mode is set in the pnmdin register, where a 1 indicates a digital input, and a 0 indicates an analog input. all pins default to digital inputs on reset. see sfr definition 13.4 for the pnmdin register details. important note: port 0 and port 1 pins are 5.25 v tolerant across the operating range of v regin . the output driver characteristics of the i/o pins ar e defined using the port output mode registers (pnmd- out). each port output driver can be configured as either open drain or push- pull. this selection is required even for the digital resources selected in the xbrn registers, and is not automatic. when the weakpud bit in xbr1 is 0, a weak pu llup is enabled for all port i/o configured as ope n-drain. weakpud does not affect the push-pull port i/o. furthermore, the weak pullup is turned off on an output that is driving a 0 and for pins configured for analog inpu t mode to avoid unnecessary power dissipation. registers xbr0 and xbr1 must be loaded with the approp riate values to select the digital i/o functions required by the design. se tting the xbare bit in xbr1 to 1 enables the crossbar. until the crossbar is enabled, the external pins remain as standard port i/o (in input mode), regardless of the xbrn register settings. for given xbrn register settings, one can de termine the i/o pin-out us ing the priority decode ta b l e . the crossbar must be enabled to use port pins as standard port i/o in output mode. port output drivers are disabled while the crossbar is disabled.
rev. 1.4 127 c8051f52x/f53x sfr definition 13.1. xbr0: port i/o crossbar register 0 bit7?6 : reserved . read = 00b; must write 00b. bit5 : cp0ae : comparator0 asynchronous output enable 0: asynchronous cp0 unavailable at port pin. 1: asynchronous cp0 routed to port pin. bit4 : cp0e : comparator0 output enable 0: cp0 unavailable at port pin. 1: cp0 routed to port pin. bit3 : syscke : /sysclk output enable 0: /sysclk unavaila ble at port pin. 1: /sysclk output r outed to port pin. bit2 : line . lin output enable bit1 : spi0e : spi i/o enable 0: spi i/o unavailable at port pins. 1: spi i/o routed to port pins. note that t he spi can be assigned either 3 or 4 gpio pins. bit0 : urt0e : uart i/o output enable 0: uart i/o unavailable at port pin. 1: uart tx0, rx0 routed to port pins (p0.3 and p0.4) or (p0.4 and p0.5).* ? note: refer to section ?20. device specific behavior? on page 210. r/w r/w r/w r/w r/w r/w r/w r/w reset value - - cp0ae cp0e syscke line spi0e urt0e 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: 0xe1
c8051f52x/f53x 128 rev. 1.4 sfr definition 13.2. xbr1: port i/o crossbar register 1 13.3. general purpose port i/o port pins that remain unassigned by the crossbar and are not used by analog peripherals can be used for general purpose i/o. ports p0 ? p1 are accessed through corresponding special function registers (sfrs) that are both byte addressable and bit addressable. wh en writing to a port, the va lue written to the sfr is latched to maintain the output data value at each pin. when reading, the logic levels of the port's input pins are returned regardless of the xbrn settings (i.e., even when the pin is assigned to another signal by the crossbar, the port register can always read its corres ponding port i/o pin). the exception to this is the execution of the read-modify-write instructions that ta rget a port latch register as the destination. the read-modify-write instructions when operating on a port sfr are the following: anl, orl, xrl, jbc, cpl, inc, dec, djnz and mov, clr or setb, when the de stination is an individual bit in a port sfr. for these instructions, the value of the latch register (not the pin) is read, modified, and written back to the sfr. bit7 : weakpud : port i/o weak pullup disable. 0: weak pullups enabled (except for ports whose i/o are configured as analog input). 1: weak pullups disabled. bit6 : xbare : crossbar enable. 0: crossbar disabled. 1: crossbar enabled. bit5 : t1e : t1 enable 0: t1 unavailable at port pin. 1: t1 routed to port pin. bit4 : t0e : t0 enable 0: t0 unavailable at port pin. 1: t0 routed to port pin. bit3 : ecie : pca0 external co unter input enable 0: eci unavailable at port pin. 1: eci routed to port pin. bit2 : reserved . must write 0b. bits1?0 : pca0me : pca module i/o enable bits. 00: all pca i/o unavailable at port pins. 01: cex0 routed to port pin. 10: cex0, cex1 routed to port pins. 11: cex0, cex1, cex2 routed to port pins. r/w r/w r/w r/w r/w r/w r/w r/w reset value weakpud xbare t1e t0e ecie reserved pca0me 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: 0xe2
rev. 1.4 129 c8051f52x/f53x in addition to performing general purpose i/o, p0 and p1 can generate a port match event if the logic lev- els of the port?s input pins match a software cont rolled value. a port matc h event is generated if (p0 & p0mask) does not equal (p0match & p0mask) or if (p1 & p1mask) does not equal (p1match & p1mask). this allows soft ware to be notified if a certain change or patte rn occurs on p0 or p1 input pins regardless of the xbrn settings. a port match event can cause an interrupt if emat (eie2.1) is set to 1 or cause the internal oscillator to awak en from suspend mode. see se ction ?14.1.1. internal oscillator suspend mode? on page 136 for more information. sfr definition 13.3. p0: port0 sfr definition 13.4. p0 mdin: port0 input mode bits7?0 : p0.[7:0] write - output appears on i/o pins per crossbar registers. 0: logic low output. 1: logic high output (high impedance if corresponding p0mdout.n bit = 0). read - always reads 0 if selected as analog input in regi ster p0mdin. directly reads port pin when configured as digital input. 0: p0.n pin is logic low. 1: p0.n pin is logic high. r/w r/w r/w r/w r/w r/w r/w r/w reset value p0.7 p0.6 p0.5 p0.4 p0.3 p0.2 p0.1 p0.0 11111111 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit addressable sfr address: 0x80 bits7?0 : analog input configuration bits for p0.7 ? p0.0 (respectively). port pins configured as analog inputs have th eir weak pullup, digital driver, and digital receiver disabled. 0: corresponding p0.n pin is configured as an analog input. 1: corresponding p0.n pin is not configured as an analog input. r/w r/w r/w r/w r/w r/w r/w r/w reset value 11111111 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: 0xf1
c8051f52x/f53x 130 rev. 1.4 sfr definition 13.5. p0md out: port0 output mode sfr definition 13.6. p0skip: port0 skip bits7?0 : output configuration bits for p0.7 ? p0.0 (respectively): ignored if corresponding bit in regis- ter p0mdin is logic 0. 0: corresponding p0.n output is open-drain. 1: corresponding p0.n output is push-pull. note: when sda and scl appear on any of the port i/o, each are open-drain regardless of the value of p0mdout. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: 0xa4 bits7?0 : p0skip[7:0] : port0 crossbar skip enable bits. these bits select port pins to be skipped by the crossbar decoder. port pins used as ana- log inputs (for adc or comparator ) or used as special functions (v ref input, external oscil- lator circuit, cnvstr input) should be skipped by the crossbar. 0: corresponding p0.n pin is not skipped by the crossbar. 1: corresponding p0.n pin is skipped by the crossbar. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: 0xd4
rev. 1.4 131 c8051f52x/f53x sfr definition 13.7. p0mat: port0 match sfr definition 13.8. p0mask: port0 mask bits7?0 : p0mat[7:0] : port0 match value. these bits control the value that unmasked p0 port pins are compared against. a port match event is generated if (p0 & p0mask) does not equal (p0mat & p0mask). r/w r/w r/w r/w r/w r/w r/w r/w reset value 11111111 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: 0xd7 bits7?0 : p0mask[7:0] : port0 mask value. these bits select which port pins will be compared to the valu e stored in p0mat. 0: corresponding p0.n pin is ignored and cannot cause a port match event. 1: corresponding p0.n pin is compared to the corresponding bit in p0mat. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: 0xc7
c8051f52x/f53x 132 rev. 1.4 sfr definition 13.9. p1: port1 sfr definition 13.10. p1 mdin: port1 input mode bits7?0 : p1.[7:0] write - output appears on i/o pins per crossbar registers. 0: logic low output. 1: logic high output (high impedance if corresponding p1mdout.n bit = 0). read - always reads 0 if selected as analog input in regi ster p1mdin. directly reads port pin when configured as digital input. 0: p1.n pin is logic low. 1: p1.n pin is logic high. r/w r/w r/w r/w r/w r/w r/w r/w reset value p1.7 p1.6 p1.5 p1.4 p1.3 p1.2 p1.1 p1.0 11111111 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit addressable sfr address: 0x90 bits7?0 : analog input configuration bits for p1.7 ? p1.0 (respectively). port pins configured as analog inputs have th eir weak pullup, digital driver, and digital receiver disabled. 0: corresponding p1.n pin is configured as an analog input. 1: corresponding p1.n pin is not configured as an analog input. r/w r/w r/w r/w r/w r/w r/w r/w reset value 11111111 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: 0xf2
rev. 1.4 133 c8051f52x/f53x sfr definition 13.11. p1md out: port1 output mode sfr definition 13.12. p1skip: port1 skip bits7?0 : output configuration bits for p1.7 ? p1.0 (respectively): ignored if corresponding bit in regis- ter p1mdin is logic 0. 0: corresponding p1.n output is open-drain. 1: corresponding p1.n output is push-pull. note: when sda and scl appear on any of the port i/o, each are open-drain regardless of the value of p0mdout. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: 0xa5 bits7?0 : p1skip[7:0] : port1 crossbar skip enable bits. these bits select port pins to be skipped by th e crossbar decoder. port pins used as ana- log inputs (for adc or comparator) or used as special functions (v ref input, external oscil- lator circuit, cnvstr input) should be skipped by the crossbar. 0: corresponding p1.n pin is not skipped by the crossbar. 1: corresponding p1.n pin is skipped by the crossbar. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: 0xd5
c8051f52x/f53x 134 rev. 1.4 sfr definition 13.13. p0skip: port0 skip sfr definition 13.14. p1mat: port1 match sfr definition 13.15. p1mask: port1 mask bits7?0 : p1skip[7:0] : port1 crossbar skip enable bits. these bits select port pins to be skipped by th e crossbar decoder. port pins used as ana- log inputs (for adc or comparator) or used as special functions (v ref input, external oscil- lator circuit, cnvstr input) should be skipped by the crossbar. 0: corresponding p1.n pin is not skipped by the crossbar. 1: corresponding p1.n pin is skipped by the crossbar. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: 0xd4 bits7?0 : p1mat[7:0] : port1 match value. these bits control the value that unmasked p0 port pins are compared against. a port match event is generated if (p1 & p1mask) does no t equal (p1mat & p1mask). r/w r/w r/w r/w r/w r/w r/w r/w reset value 11111111 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: 0xcf bits7?0: p1mask[7:0] : port1 mask value. these bits select which port pins will be compared to the valu e stored in p1mat. 0: corresponding p1.n pin is ignored and cannot cause a port match event. 1: corresponding p1.n pin is compared to the corresponding bit in p1mat. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: 0xbf
rev. 1.4 135 c8051f52x/f53x 14. oscillators c8051f52x/f52xa/f53x/f53xa devices include a programma ble internal oscillator, an external oscillator drive circuit. the internal oscilla tor can be enabled/disabled and calibrated using the oscicn and oscicl registers, as shown in fi gure 14.1. the system clock (sysclk) can be derived from the internal oscillator, external oscillator circuit. oscillator electrical specifications are given in table 2.11 on page 34. figure 14.1. oscillator diagram 14.1. programmable internal oscillator all c8051f52x/53x devices include a programmable internal os cillator that defaults as the system clock after a system reset. the internal oscillator period can be programmed via the oscicl and oscifin reg- isters, shown in sfr definition 14 .2 and sfr definition 14.3. on c8051f52x/53x devices, oscicl and oscifin are factory calibrated to obtain a 24.5 mhz frequency. electrical specifications for the prec ision internal oscillator are given in table 2.11 on page 34. note that the system clock may be derived from the programmed internal oscillator di vided by 1, 2, 4, 8, 16, 32, 64, or 128 as defined by the ifcn bits in register oscicn. the divide value defaults to 128 following a reset. osc exosc input circuit xtlvld xtal1 xtal2 option 2 vdd xtal2 option 1 10m ? option 3 xtal2 option 4 xtal2 oscxcn xtlvld xoscmd2 xoscmd1 xoscmd0 xfcn2 xfcn1 xfcn0 programmable internal clock generator en oscicn ioscen1 ioscen0 suspend ifrdy ifcn1 ifcn0 iosc sysclk clksel clksl n ifcn2 oscicl oscifin
c8051f52x/f53x 136 rev. 1.4 14.1.1. internal os cillator suspend mode when software writes a logic 1 to suspend (oscicn.5) , the internal oscillator is suspended. if the sys- tem clock is derived from t he internal oscillator, the input clock to the peripheral or cip-51 will be stopped until one of the following events occur: ? port 0 match event. ? port 1 match event. ? comparator 0 enabled and output is logic 0. when one of the intern al oscillator awakening events occur, the internal oscillator, cip-51, and affected peripherals resume normal operation, regardless of whether the event also causes an interrupt. the cpu resumes execution at the instructio n following the write to suspend. note: please refer to section ?20.7. internal oscillator suspend mode? on page 212 for a note about suspend mode in older silicon revisions.
rev. 1.4 137 c8051f52x/f53x sfr definition 14.1. oscicn: in ternal oscillator control bits7?6 : ioscen[1:0] : internal oscillator enable bits. 00: oscillator disabled. 01: reserved. 10: reserved. 11: oscillator enabled in normal mode and disabled in suspend mode. bit5: suspend : internal oscillator suspend enable bit. setting this bit to logic 1 places the internal oscillator in suspend mo de. the internal oscil- lator resumes op eration when one of the suspend mode awakening events occur. bit4: ifrdy : internal oscillator frequency ready flag. 0: internal oscillator is not running at prog rammed frequency. 1: internal oscillator is r unning at progra mmed frequency. bit3: unused . read = 0b, write = don't care. bits2?0 : ifcn2?0 : internal oscillator frequency control bits. 000: sysclk derived from internal oscillator divided by 128 (default). 001: sysclk derived from inte rnal oscillator divided by 64. 010: sysclk derived from inte rnal oscillator divided by 32. 011: sysclk derived from intern al oscillator divided by 16. 100: sysclk derived from inte rnal oscillator divided by 8. 101: sysclk derived from inte rnal oscillator divided by 4. 110: sysclk derived from inte rnal oscillator divided by 2. 111: sysclk derived from intern al oscillator divided by 1. r/w r/w r/w r r r/w r/w r/w reset value ioscen1 ioscen0 suspend ifrdy ? ifcn2 ifcn1 ifcn0 11000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: 0xb2
c8051f52x/f53x 138 rev. 1.4 sfr definition 14.2. oscicl: inte rnal oscillator calibration sfr definition 14.3. oscifin: intern al fine oscillator calibration bit7: unused . read = 0b. write = don?t care. bits6?0 : oscicl : internal oscillator calibration register. this register determines the inte rnal oscillator period. on c8051f52x/53x devices, the reset value is factory calibrated to generate an internal osc illator frequency of 24.5 mhz. r r/w r/w r/w r/w r/w r/w r/w reset value ?o s c i c lv a r i e s bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: 0xb3 bits7?6 : unused . read = 00b, write = don't care. bits5?0 : oscifin . internal oscillator fi ne adjustment bits. the valid range is between 0x00 and 0x27. this register is a fine adjustment fo r the internal osc illator period. on c8051f52x/52xa/53x/53xa devices, the reset value is factory calibrated to generate an internal oscillator frequency of 24.5 mhz. r/w r/w r/w r r r/w r/w r/w reset value ? ? oscifin undetermined bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit addressable sfr address: 0xb0
rev. 1.4 139 c8051f52x/f53x 14.2. external osci llator drive circuit the external oscillator circuit may drive an external cr ystal, ceramic resona tor, capacitor, or rc network. a cmos clock may also provide a clock input. for a cr ystal or ceramic resonator configuration, the crys- tal/resonator must be wired across the xtal1 and xt al2 pins as shown in option 1 of figure 14.1. a 10 m ?? resistor also must be wired across the xtal1 an d xtal2 pins for the crystal/resonator configura- tion. in rc, capacitor, or cmos cl ock configuration, the clock source should be wired to the xtal2 pin as shown in option 2, 3, or 4 of figure 14.1. the type of external oscillator must be selected in the oscxcn register, and the frequency control bits (xfcn) must be selected appropriately (see sfr definition 14.4. oscxcn: external oscillator control). important note on external oscillator usage: port pins must be configured when using the external oscillator circuit. when the external oscillator drive ci rcuit is enabled in crystal/resonator mode, port pins p0.7 and p1.0 ('f53x/'f53xa) or p0.2 and p0.3 ('f52x/'f52xa) are used as xtal1 and xtal2 respec- tively. when the external oscillator drive circuit is enabled in capacitor, rc, or cmos clock mode, port pin p1.0 ('f53x/'f53xa) or p0.3 ('f52x/'f52xa) is used as xtal2. the port i/o crossbar should be configured to skip the port pins used by the oscillator circuit; see section ?13.1. priori ty crossbar decoder? on page 122 for crossbar configuration. additionally, when using the external oscillator circuit in crystal/reso- nator, capacitor, or rc mode, the associated port pins should be configured as analog inputs . in cmos clock mode, the associated pin should be configured as a digital input . see section ?13.2. port i/o initial- ization? on page 126 for details on port input mode selection. 14.2.1. clocking timers directly through the external oscillator the external oscillator source divided by eight is a clock option for the timers (section ?18. timers? on page 182) and the programmable counter array (pca) (section ?19. programmable counter array (pca0)? on page 195). when the external oscillator is used to clock these peripherals, but is not used as the system clock, the external o scillator frequency must be less than or equal to the system clock fre- quency. in this configuration, the clock supplied to the peripheral (exter nal oscillator / 8) is synchronized with the system clock; the jitter associated with this sy nchronization is limited to 0.5 system clock cycles. 14.2.2. external crystal example if a crystal or ceramic resonator is used as an external oscillator source for the mcu, the circuit should be configured as shown in figure 14.1 , option 1. the external oscillato r frequency contro l value (xfcn) should be chosen from the crystal column of the tabl e in sfr definition 14.4. for example, a 12 mhz crys- tal requires an xfcn setting of 111b. when the crystal oscillator is first e nabled, the oscillator amplitude detecti on circuit requires a settling time to achieve proper bias. introduc ing a delay of 1 ms between enab ling the oscillator and checking the xtlvld bit will prevent a premature switch to the extern al oscillator as the system clock. switching to the external oscillator before the crysta l oscillator has stabilized can result in unpredictable behavior. the rec- ommended procedure is: 1. configure xtal1 and xtal2 pins by writing 1 to the port latch. 2. configure xtal1 and xtal2 as analog inputs. 3. enable the external oscillator. 4. wait at least 1 ms. 5. poll for xtlvld => 1. 6. switch the system clock to the external oscillator. note: tuning-fork crystals may require additional settling time before xtlvld returns a valid result. the capacitors shown in the external crystal configur ation provide the load capacitance required by the crystal for correct oscillation. these capacitors are "in series" as seen by the crystal and "in parallel" with the stray capacitance of the xtal1 and xtal2 pins.
c8051f52x/f53x 140 rev. 1.4 note: the load capacitance depends upon the crystal an d the manufacturer. please refer to the crystal data sheet when completing these calculations. the equation for determining the load capacitance for two capacitors is: where: c a and c b are the capacitors connec ted to the crystal leads. c s is the total stray capacitance of the pcb. the stray capacitance for a typical layout where the crysta l is as close as possible to the pins is 2?5 pf per pin. if c a and c b are the same (c), then the equation becomes: for example, a tuning-fork crystal of 32 khz with a recommended load capacitance of 12.5 pf should use the configuration shown in figure 14.1, option 1. with a stray capacitance of 3 pf per pin (6 pf total), the 13 pf capacitors yield an equivalent capacitance of 12.5 pf across the crystal, as shown in figure 14.2. figure 14.2. 32 khz external crystal example important note on external crystals: crystal oscillator circuits are qui te sensitive to pcb layout. the crystal should be placed as close as possible to the xtal pins on the device. the traces should be as short as possible and shielded with ground plane fr om any other traces which could introduce noise or interference. c l c a c b ? c a c b + -------------------- c s + = c l c 2 --- - c s += 13 pf 13 pf 32 khz xtal1 xtal2 10 m ? ?
rev. 1.4 141 c8051f52x/f53x 14.2.3. external rc example if an rc network is used as an external oscillator so urce for the mcu, the circ uit should be configured as shown in figure 14.1, option 2. the capacitor should be no greater than 100 pf; however for very small capacitors, the total capacitance may be dominated by parasitic capacitance in the pcb layout. to deter- mine the required external oscilla tor frequency control va lue (xfcn) in the oscxcn register, first select the rc network value to prod uce the desired frequency of oscilla tion. if the frequency desired is 100 khz, let r = 246 k ? and c = 50 pf: f = 1.23( 10 3 ) / rc = 1.23 ( 10 3 ) / [ 246 x 50 ] = 0.1 mhz = 100 khz referring to the table in sfr defini tion 14.4, the required xfcn setting is 010b. programming xfcn to a higher setting in rc mode will improve frequency accuracy at a slightly increased external oscillator supply current. 14.2.4. external capacitor example if a capacitor is used as an external oscillator for t he mcu, the circuit should be configured as shown in figure 14.1, option 3. the capacitor should be no gr eater than 100 pf; however for very small capacitors, the total capacitance may be dominated by parasiti c capacitance in the pcb layout. to determine the required external oscilla tor frequency control valu e (xfcn) in the oscxcn register, select the fre- quency of oscillation a nd calculate the capacitance to be used from the equation s below. assume v dd = 2.1 v and f = 75 khz: f = kf / (c x v dd ) 0.075 mhz = kf / (c x 2.1) since the frequency of roughly 75 khz is desired, select the k factor from the table in sfr definition 14.4 as kf = 7.7: 0.075 mhz = 7.7 / (c x 2.1) c x 2.1 = 7.7 / 0.075 mhz c = 102.6 / 2.0 pf = 51.3 pf therefore, the xfcn value to use in this example is 010b.
c8051f52x/f53x 142 rev. 1.4 sfr definition 14.4. oscxcn: ex ternal oscillator control bit7: xtlvld : crystal oscillator valid flag. (read only when xoscmd = 11x.) 0: crystal oscillator is unused or not yet stable. 1: crystal oscillator is running and stable. bits6?4 : xoscmd2?0 : external oscillator mode bits. 00x: external osc illator circuit off. 010: external cmos clock mode. 011: external cmos clock mode with divide by 2 stage. 100: rc oscillator mode. 101: capacitor oscillator mode. 110: crystal oscillator mode. 111: crystal oscillator mode with divide by 2 stage. bit3: reserved . read = 0b; must write 0b. bits2?0 : xfcn2?0 : external oscillator fr equency control bits. 000-111: see table below: crystal mode (circuit from figure 14.1, option 1; xoscmd = 11x) choose xfcn value to match crystal or resonator frequency. rc mode (circuit from figure 14.1, option 2; xoscmd = 10x) choose xfcn value to match frequency range: f = 1.23(10 3 ) / (r x c) , where f = frequency of clock in mhz c = capacitor value in pf r = pullup resistor value in k ? c mode (circuit from figure 14.1, option 3; xoscmd = 10x) choose k factor (kf) for the oscillation frequency desired: f = kf / (c x v dd ) , where f = frequency of clock in mhz c = capacitor value the xtal2 pin in pf v dd = power supply on mcu in volts r r/w r/w r/w r/w r/w r/w r/w reset value xtlvld xoscmd2 xoscmd1 xoscmd0 reserved xfcn2 xfcn1 xfcn0 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: 0xb1 xfcn crystal (xoscmd = 11x) rc (xoscmd = 10x) c (xoscmd = 10x) 000 f ? 20 khz f ?? 25 khz k factor = 0.87 001 20 khz ?? f ?? 58 khz 25 khz ?? f ?? 50 khz k factor = 2.6 010 58 khz ? f ?? 155 khz 50 khz ?? f ?? 100 khz k factor = 7.7 011 155 khz ? f ?? 415 khz 100 khz ?? f ?? 200 khz k factor = 22 100 415 khz ? f ?? 1.1 mhz 200 khz ?? f ?? 400 khz k factor = 65 101 1.1 mhz ? f ?? 3.1 mhz 400 khz ?? f ?? 800 khz k factor = 180 110 3.1 mhz ? f ?? 8.2 mhz 800 khz ?? f ?? 1.6 mhz k factor = 664 111 8.2 mhz ? f ?? 25 mhz 1.6 mhz ?? f ?? 3.2 mhz k factor = 1590
rev. 1.4 143 c8051f52x/f53x 14.3. system clock selection the internal oscillator requir es little start-up time and may be selected as the system clock immediately fol- lowing the oscicn write that enables the internal oscillator. external crystals and ceramic resonators typ- ically require a start-up time before they are settle d and ready for use. the crystal valid flag (xtlvld in register oscxcn) is set to 1 by hardware when the external oscillator is settled. to avoid reading a false xtlvld in crystal mode, the software should delay at least 1 ms between enabling the external oscillator and checking xtlvld. rc and c modes typically require no startup time. the clksl bit in register clksel selects which osc illator source is used as the system clock. clksl must be set to 1 for the system clo ck to run from the external oscillator; however the external oscillator may still clock certain peripherals (timers, pca) when another oscillator is se lected as the system clock. the system clock may be switched on-the-fly between t he internal oscillator and extern al oscillator, as long as the selected clock source is enabled and has settled. sfr definition 14.5. clksel: clock select bits7?6 : unused. read = 00b; write = don?t care. bits5?4 : reserved. read = 00b; must write 00b. bit3 : unused. read = 0b; write = don?t care. bits2?1 : reserved. read = 00b; must write 00b. bit0: clksl : system clock select 0: internal oscillator (as determined by the ifcn bi ts in register oscicn). 1: external oscillator. r r r/w r/w r r/w r/w r/w reset value - - reserved reserved - reserved reserved clksl 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: 0xa9
c8051f52x/f53x 144 rev. 1.4 15. uart0 uart0 is an asynchronous, full duplex serial port offering modes 1 and 3 of the standard 8051 uart. enhanced baud rate support allows a wide range of clock sources to generate standard baud rates (details in section ?15.1. enhanced baud rate generation? on page 145). received data buffering allows uart0 to start reception of a second incoming data byte be fore software has finished reading the previous data byte. (pleas e refer to section ?20. device specific behavior? on page 210 for more information on the pins asso- ciated with the uart interface.) uart0 has two associated sfrs: serial control regist er 0 (scon0) and serial data buffer 0 (sbuf0). the single sbuf0 location provides access to both transmit and receive registers. writes to sbuf0 always access the transmit register. reads of sbuf0 always access the buffered receive register; it is not possible to read data from the transmit register. with uart0 interrupts enabled, an interrupt is generate d each time a transmit is completed (ti0 is set in scon0), or a data byte has been received (ri0 is set in scon0). the uart 0 interrupt flags are not cleared by hardware when the cpu vectors to the interr upt service routine. they must be cleared manually by software, allowing software to determine the cause of the uart0 interrupt (transmit complete or receive complete). figure 15.1. uart0 block diagram uart baud rate generator ri scon ri ti rb8 tb8 ren mce smode tx control tx clock send sbuf (tx shift) start data write to sbuf crossbar tx shift zero detector tx irq set qd clr stop bit tb8 sfr bus serial port interrupt ti port i/o rx control start rx clock load sbuf shift 0x1ff rb8 rx irq input shift register (9 bits) load sbuf read sbuf sfr bus crossbar rx sbuf (rx latch)
rev. 1.4 145 c8051f52x/f53x 15.1. enhanced ba ud rate generation the uart0 baud rate is generated by timer 1 in 8-bit auto-reload mode. the tx clock is generated by tl1; the rx clock is generated by a copy of tl1 (shown as rx timer in figure 15.2), which is not user- accessible. both tx and rx timer overflows are divid ed by two to generate the tx and rx baud rates. the rx timer runs when timer 1 is enabled, and uses the same reload value (th1). however, an rx timer reload is forced when a start condition is detected on the rx pin. this allows a receive to begin any time a start is detected, independent of the tx timer state. figure 15.2. uart0 baud rate logic timer 1 should be configured for mode 2, 8-bit aut o-reload (see section ?18.1.3. mode 2: 8-bit coun- ter/timer with auto-reload? on p age 184). the timer 1 reload value should be set so that overflows will occur at two times the desired uart baud rate frequenc y. note that timer 1 may be clocked by one of six sources: sysclk, sysclk / 4, sysclk / 12, sysclk / 48 , the external o scillator clock / 8, or an exter- nal input t1. the uart0 baud rate is determined by equation 15.1-a and equation 15.1-b. equation 15.1. uart0 baud rate where t1 clk is the frequency of the clock supplied to timer 1, and t1h is the high byte of timer 1 (8-bit auto-reload mode reload value). timer 1 clock frequency is selected as described in section ?18. timers? on page 182. a quick reference for typical baud rates and system clock frequencies is given in table 15.1. note that the internal os cillator may still genera te the system clock wh en the external oscillator is driving timer 1. rx timer start detected overflow overflow th1 tl1 tx clock 2 rx clock 2 timer 1 uart uartbaudrate 1 2 -- - x t1_overflow_rate = t1_overflow_rate t1 clk 256 th1 ? -------------------------- - = a) b)
c8051f52x/f53x 146 rev. 1.4 15.2. operational modes uart0 provides standard asynchronous, full duplex communication. the uart mode (8-bit or 9-bit) is selected by the s0mode bit (scon0.7). typical uart connection options are shown below. figure 15.3. uart interconnect diagram 15.2.1. 8-bit uart 8-bit uart mode uses a total of 10 bits per data byte: one start bit, eight data bits (lsb first), and one stop bit. data are transmitted lsb first from the tx0 pin a nd received at the rx0 pin. on receive, the eight data bits are stored in sbuf0 and the stop bit goes into rb80 (scon0.2). data transmission begins wh en software writes a data byte to th e sbuf0 register. the ti0 transmit inter- rupt flag (scon0.1) is set at the end of the transmi ssion (the beginning of the st op-bit time). data recep- tion can begin any time after the ren0 receive enable bi t (scon0.4) is set to logic 1. after the stop bit is received, the data byte w ill be loaded into the sbuf0 re ceive register if the follo wing conditions are met: ri0 must be logic 0, and if mce0 is logic 1, the stop bit must be logic 1. in the event of a receive data over- run, the first received 8 bits are la tched into the sbuf0 receive register and the following overrun data bits are lost. if these conditions are met, the eight bits of data is stor ed in sbuf0, the stop bit is stored in rb80 and the ri0 flag is set. if these conditio ns are not met, sbuf0 and rb80 will no t be loaded and the ri0 flag will not be set. an interrupt will occur if enabled when ei ther ti0 or ri0 is set. figure 15.4. 8-bit uart timing diagram or rs-232 c8051fxxx rs-232 level xltr tx rx c8051fxxx rx tx mcu rx tx d1 d0 d2 d3 d4 d5 d6 d7 start bit mark stop bit bit times bit sampling space
rev. 1.4 147 c8051f52x/f53x 15.2.2. 9-bit uart 9-bit uart mode uses a total of eleven bits per data byte: a start bit, 8 data bits (lsb first), a programma- ble ninth data bit, and a stop bit. the state of the nint h transmit data bit is determ ined by the value in tb80 (scon0.3), which is assigned by user software. it can be assigned the value of the parity flag (bit p in reg- ister psw) for error detection, or used in multiprocessor communications. on receive, the ninth data bit goes into rb80 (scon0.2) and the stop bit is ignored. data transmission begins when an instruction writes a data byte to the sbuf0 register. the ti0 transmit interrupt flag (scon0.1) is set at the end of the tran smission (the beginning of the stop-bit time). data reception can begin any time after the ren0 receive enab le bit (scon0.4) is set to 1. after the stop bit is received, the data byte w ill be loaded into the sbuf0 re ceive register if the follo wing conditions are met: (1) ri0 must be logic 0, and (2) if mce0 is logic 1, the 9th bit must be logic 1 (when mce0 is logic 0, the state of the ninth data bit is unimportant). if these cond itions are met, the eight bits of data are stored in sbuf0, the ninth bit is stored in rb80, and the ri0 flag is set to 1. if the above conditions are not met, sbuf0 and rb80 will not be loaded and the ri0 flag will not be set to 1. a uart 0 interrupt will occur if enabled when either ti0 or ri0 is set to 1. figure 15.5. 9-bit uart timing diagram d1 d0 d2 d3 d4 d5 d6 d7 start bit mark stop bit bit times bit sampling space d8
c8051f52x/f53x 148 rev. 1.4 15.3. multiprocessor communications 9-bit uart mode supports multiprocessor communication between a master processor and one or more slave processors by special use of t he ninth data bit. when a master processor wants to transmit to one or more slaves, it first sends an address byte to select th e target(s). an address byte differs from a data byte in that its ninth bit is logic 1; in a data byte, the ninth bit is always set to logic 0. setting the mce0 bit (scon0.5) of a slave processor co nfigures its uart such that when a stop bit is received, the uart will generat e an interrupt only if the ninth bit is logic 1 (rb80 = 1) signifying an address byte has been received. in the uart interrupt handler, software will compare the received address with the slave's own assigned 8-bit addre ss. if the addresses match, the slav e will clear its mce0 bit to enable interrupts on the reception of the following data byte (s). slaves that weren't addressed leave their mce0 bits set and do not generate interrupts on the reception of the following data bytes, thereby ignoring the data. once the entire message is rece ived, the addressed slave resets its mce0 bit to ignore all transmis- sions until it receives the next address byte. multiple addresses can be assigned to a single sl ave and/or a single address can be assigned to multiple slaves, thereby enabling "broadcast" transmissions to more than one slave simultaneously. the master processor can be configured to receive all transmissi ons or a protocol can be implemented such that the master/slave role is tem porarily reversed to enable half-duplex transmission between the original master and slave(s). figure 15.6. uart multi-pr ocessor mode interconnect diagram master device slave device tx rx rx tx slave device rx tx slave device rx tx v+
rev. 1.4 149 c8051f52x/f53x sfr definition 15.1. scon0: serial port 0 control bit7: s0mode : serial port 0 operation mode. this bit selects the uart0 operation mode. 0: 8-bit uart with variable baud rate. 1: 9-bit uart with variable baud rate. bit6: unused . read = 1b. write = don?t care. bit5: mce0: multiprocessor co mmunication enable. the function of this bit is dependent on the serial port 0 operation mode. s0mode = 0: checks for valid stop bit. 0: logic level of stop bit is ignored. 1: ri0 will only be activated if stop bit is logic level 1. s0mode = 1: multiprocesso r communications enable. 0: logic level of ninth bit is ignored. 1: ri0 is set and an interrupt is generated only when the ninth bit is logic 1. bit4: ren0: receive enable. this bit enables/disables the uart receiver. 0: uart0 reception disabled. 1: uart0 reception enabled. bit3: tb80 : ninth transmission bit. the logic level of this bit will be assigned to the ninth transmission bit in 9-bit uart mode. it is not used in 8-bit uart mode. set or cleared by software as required. bit2: rb80 : ninth receive bit. rb80 is assigned the value of the stop bit in mode 0; it is assigned the value of the 9th data bit in mode 1. bit1: ti0 : transmit interrupt flag. set by hardware when a byte of data has been transmitted by uart0 (after the 8th bit in 8- bit uart mode, or at the beginning of the stop bit in 9-bit uart mode). when the uart0 interrupt is enabled, setting this bit causes the cpu to vector to the uart0 interrupt service routine. this bit must be cleared manually by software. bit0: ri0 : receive interrupt flag. set to 1 by hardware when a byte of data has been received by uart0 (set at the stop bit sampling time). when the uart0 interrupt is enab led, setting this bit to 1 causes the cpu to vector to the uart0 interrupt service routine. this bit must be cleared manually by software. r/w r r/w r/w r/w r/w r/w r/w reset value s0mode - mce0 ren0 tb80 rb80 ti0 ri0 01000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit addressable sfr address: 0x98
c8051f52x/f53x 150 rev. 1.4 sfr definition 15.2. sbuf0: seri al (uart0) port data buffer table 15.1. timer settings for standard baud rates ? using the internal oscillator frequency: 24.5 mhz target baud rate (bps) baud rate % error oscillator divide factor timer clock source sca1?sca0 (pre-scale select)* t1m* timer 1 reload value (hex) sysclk from internal osc. 230400 ? 0.32% 106 sysclk xx 1 0xcb 115200 ? 0.32% 212 sysclk xx 1 0x96 57600 0.15% 426 sysclk xx 1 0x2b 28800 ? 0.32% 848 sysclk / 4 01 0 0x96 14400 0.15% 1704 sysclk / 12 00 0 0xb9 9600 ? 0.32% 2544 sysclk / 12 00 0 0x96 2400 ? 0.32% 10176 sysclk / 48 10 0 0x96 1200 0.15% 20448 sysclk / 48 10 0 0x2b x = don?t care note: sca1 ? sca0 and t1m bit definitions can be found in section 18.1. bits7?0 : sbuf0[7:0] : serial data buffer bits 7 ? 0 (msb ? lsb) this sfr accesses two registers; a transmit shif t register and a receive latch register. when data is written to sbuf0, it goes to the transmit shift register and is he ld for serial transmis- sion. writing a byte to sbuf0 initiates the transmission. a read of sbuf0 returns the con- tents of the receive latch. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: 0x99
rev. 1.4 151 c8051f52x/f53x 16. enhanced serial pe ripheral interface (spi0) the serial peripheral interface (spi0) provides acce ss to a flexible, full-duplex synchronous serial bus. spi0 can operate as a master or slave device in both 3-wire or 4-wire modes, and supports multiple mas- ters and slaves on a single spi bus. the slave-select (nss) signal can be configured as an input to select spi0 in slave mode, or to disable master mode operation in a multi-master environment, avoiding conten- tion on the spi bus when more than one master atte mpts simultaneous data transfers. nss can also be configured as a chip-select output in master mode, or disabled for 3-wire operation. additional general pur- pose port i/o pins can be used to select multiple sl ave devices in master mode. figure 16.1. spi block diagram sfr bus data path control sfr bus write spi0dat receive data buffer spi0dat 0 1 2 3 4 5 6 7 shift register spi control logic spi0ckr scr7 scr6 scr5 scr4 scr3 scr2 scr1 scr0 spi0cfg spi0cn pin interface control pin control logic c r o s s b a r port i/o read spi0dat spi irq tx data rx data sck mosi miso nss transmit data buffer clock divide logic sysclk ckpha ckpol slvsel nssmd1 nssmd0 spibsy msten nssin srmt rxbmt spif wcol modf rxovrn txbmt spien
c8051f52x/f53x 152 rev. 1.4 16.1. signal descriptions the four signals used by spi0 (mosi, miso, sck, nss) are described below. 16.1.1. master out, slave in (mosi) the master-out, slave-in (mosi) signal is an output fr om a master device and an input to slave devices. it is used to serially transfer data from the master to th e slave. this signal is an output when spi0 is operat- ing as a master and an input when spi0 is operating as a slave. data is transferred most-significant bit first. when configured as a master, mosi is driven by the msb of the shift register in both 3- and 4-wire mode. 16.1.2. master in, slave out (miso) the master-in, slave-out (miso) signal is an output from a slave device and an input to the master device. it is used to serially transfer data from the slave to the master. this signal is an input when spi0 is operat- ing as a master and an output when spi0 is operating as a slave. data is transferred most-significant bit first. the miso pin is placed in a high-impedance stat e when the spi module is disabled and when the spi operates in 4-wire mode as a slave that is not select ed. when acting as a slave in 3-wire mode, miso is always driven by the msb of the shift register. 16.1.3. serial clock (sck) the serial clock (sck) signal is an output from the mast er device and an input to slave devices. it is used to synchronize the transfer of data between the mast er and slave on the mosi and miso lines. spi0 gen- erates this signal when operating as a master. the sck signal is ignored by a spi slave when the slave is not selected (nss = 1) in 4-wire slave mode. 16.1.4. slave select (nss) the function of the slave-select (nss) signal is dependent on the setting of the nssmd1 and nssmd0 bits in the spi0cn register. there are three possib le modes that can be selected with these bits: 1. nssmd[1:0] = 00: 3-wire master or 3-wire slave mode: spi0 operates in 3-wire mode, and nss is disabled. when operating as a slave device, spi0 is always selected in 3-wire mode. since no select signal is present, spi0 must be the only slave on the bus in 3-wire mode. this is intended for point-to- point communication between a master and one slave. 2. nssmd[1:0] = 01: 4-wire slave or multi-master mode: spi0 operates in 4-wire mode, and nss is enabled as an input. when operating as a slave, nss selects the spi0 device. when operating as a master, a 1-to-0 transition of the nss signal disabl es the master function of spi0 so that multiple master devices can be used on the same spi bus. 3. nssmd[1:0] = 1x: 4-wire master mode: spi0 oper ates in 4-wire mode, and nss is enabled as an output. the setting of nssmd0 dete rmines what logic level the nss pin will output. this configuration should only be used when operating spi0 as a master device. see figure 16.2, figure 16.3, and figure 16.4 for typi cal connection diagrams of the various operational modes. note that the setting of nssmd bits affects the pinout of the device. when in 3-wire master or 3-wire slave mode, the nss pin will not be mapped by the crossbar. in all other modes, the nss signal will be mapped to a pin on the device. see section ?13. port input/output? on page 120 for general purpose port i/o and crossbar information.
rev. 1.4 153 c8051f52x/f53x 16.2. spi0 master mode operation a spi master device initiates all data transfers on a spi bus. spi0 is placed in master mode by setting the master enable flag (msten, spi0cn.6). writing a byte of data to the spi0 data register (spi0dat) when in master mode writes to the transmit buffer. if the spi shift register is empty, the byte in the transmit buffer is moved to the shift register, and a data transfer begins. the spi0 master immediately shifts out the data serially on the mosi line while provid ing the serial clock on sck. the spi f (spi0cn.7) flag is set to logic 1 at the end of the transfer. if interrupts are enabl ed, an interrupt request is generated when the spif flag is set. while the spi0 master transf ers data to a slave on the mosi line, the addressed spi slave device simultaneously transfers data to the spi master on the miso line in a full-duplex operation. therefore, the spif flag serves as both a transmit -complete and receive-data-ready flag. the data byte received from the slave is transferred msb-first into the master's shift regi ster. when a byte is fully shifted into the register, it is moved to the receive buffer where it can be read by the processor by reading spi0dat. when configured as a master, spi0 can operate in one of three different modes: multi-master mode, 3-wire single-master mode, and 4-wire single-master mode. the default, multi-master mode is active when nssmd1 (spi0cn.3) = 0 and nssmd0 (spi0cn.2) = 1. in this mode, nss is an input to the device, and is used to disable the master spi0 when another mast er is accessing the bus. when nss is pulled low in this mode, msten (spi0cn.6) and spien (spi0cn.0) are set to 0 to disable the spi master device, and a mode fault is generate d (modf, spi0cn.5 = 1). mode fault will gen erate an inte rrupt if e nabled. spi0 must be manually re-enabled in soft ware under these circumstances. in multi-master systems, devices will typically default to being slave devices while they are not acting as the system master device. in multi-mas- ter mode, slave devices can be addressed individua lly (if needed) using general-purpose i/o pins. figure 16.2 shows a connection diagram between two master devices in multiple-mas ter mode. 3-wire single-master mode is active when nssmd1 (s pi0cn.3) = 0 and nssmd0 ( spi0cn.2) = 0. in this mode, nss is not used and is not mapped to an extern al port pin through the cr ossbar. any slave devices that must be addressed in this mode should be selected using general-purpose i/o pins. figure 16.3 shows a connection diagram between a master dev ice in 3-wire master mode and a slave device. 4-wire single-master mode is active when nssmd1 (spi0cn.3) = 1. in this mode, nss is configured as an output pin and can be used as a slave-select signal for a single spi device. in this mode , the output value of nss is controlled (in software) with the bit nssm d0 (spi0cn.2). additional slave devices can be addressed using general-purpose i/o pins. figure 16.4 shows a connection diagram for a master device in 4-wire master mode and two slave devices.
c8051f52x/f53x 154 rev. 1.4 figure 16.2. multiple-master mode connection diagram figure 16.3. 3-wire single master and slave mode connection diagram figure 16.4. 4-wire single master and slave mode connection diagram 16.3. spi0 slave mode operation when spi0 is enabled and not confi gured as a master, it will operate as a spi slave. as a slave, bytes are shifted in through the mosi pin a nd out through the miso pin by a ma ster device controlling the sck sig- nal. a bit counter in the spi0 logic counts sck edges. when 8 bits have been shifted into the shift register, the spif flag is set to logic 1, and the byte is copied into the receive buffer. data is read from the receive buffer by reading spi0dat. a slave device cannot initia te transfers. data to be transferred to the master device is pre-loaded into the shift register by writ ing to spi0dat. writes to spi0dat are double-buffered, and are placed in the transmit buffer first. if the shift register is empty, the contents of the transmit buffer will immediately be transferred into the shift register. when the shift register already contains data, the spi will load the shift register with the tran smit buffer?s contents after the last sck edge of the ne xt (or current) spi transfer. master device 2 master device 1 mosi miso sck miso mosi sck nss gpio nss gpio slave device master device mosi miso sck miso mosi sck slave device master device mosi miso sck miso mosi sck nss nss gpio slave device mosi miso sck nss
rev. 1.4 155 c8051f52x/f53x the shift register contents are locked after the slave de tects the first edge of sck. writes to spi0dat that occur after the first sck edge will be held in the tx latch until the end of the current transfer. when configured as a slave, spi0 can be configured for 4-wire or 3-wire operation. the default, 4-wire slave mode, is active when nssmd1 (spi0cn.3) = 0 and nssmd0 (spi0cn.2) = 1. in 4-wire mode, the nss signal is routed to a port pin and configured as a digital input. spi0 is enabl ed when nss is logic 0, and disabled when nss is logic 1. the bit counter is reset on a falling edge of n ss. note that the nss sig- nal must be driven low at least 2 system clocks before the first active edge of sck for each byte transfer. figure 16.4 shows a connection diagram between tw o slave devices in 4-wire slave mode and a master device. 3-wire slave mode is active when nssmd1 (spi0cn. 3) = 0 and nssmd0 (spi0cn.2) = 0. nss is not used in this mode, and is not mapped to an external port pin through the crossbar. since there is not a way of uniquely addressing the device in 3-wire slave mo de, spi0 must be the only slave device present on the bus. it is important to note that in 3-wire slave mode there is no external means of resetting the bit counter that determines when a full byte has been received. th e bit counter can only be reset by disabling and re- enabling spi0 with the spien bit. figure 16.3 shows a connection diagram between a slave device in 3- wire slave mode and a master device. 16.4. spi0 interrupt sources when spi0 interrupts are e nabled, the following four flags will gener ate an interrupt when they are set to logic 1: note that all of the follo wing interrupt bits must be cleared by software. 1. the spi interrupt flag, spif (spi0cn.7) is set to logi c 1 at the end of each byte transfer. this flag can occur in all spi0 modes. 2. the write collision flag, wcol (spi0cn.6) is set to logic 1 if a write to spi0dat is attempted when the transmit buffer has not been emptied to the spi shift register. when this occurs, the write to spi0dat will be ignored, and the tr ansmit buffer will not be written.this flag can occur in all spi0 modes. 3. the mode fault flag modf (spi0cn.5) is set to logic 1 when spi0 is configured as a master in multi- master mode and the nss pin is pulled low. when a mode fault occurs, the msten and spien bits in spi0cn are set to logic 0 to disable spi0 and a llow another master device to access the bus. 4. the receive overrun flag rxovrn (spi0cn.4) is se t to logic 1 when configured as a slave, and a transfer is completed while the receive buffer still holds an unre ad byte from a previous transfer. the new byte is not transferred to the receive buffer, allowing the previously received data byte to be read. the data byte which caused the overrun is lost.
c8051f52x/f53x 156 rev. 1.4 16.5. serial clock timing four combinations of serial clock phase and polarity can be selected using the clock control bits in the spi0 configuration register (spi0cfg). the ckpha bit ( spi0cfg.5) selects one of two clock phases (edge used to latch the data). the ckpol bit (spi0cfg.4) se lects between a rising edge or a falling edge. both master and slave devices must be configured to use the same clock phase and polarity. spi0 should be disabled (by clearing the spien bit, spi0cn.0) wh en changing the clock phase or polarity. the clock and data line relationships are shown in figure 16.5. the spi0 clock rate register (spi0c kr) as shown in sfr definition 16.3 controls the master mode serial clock frequency. this register is ignored when operating in slave mode. when the spi is configured as a master, the maximum data transfer rate (bits/sec) is one-half the s ystem clock frequency or 12.5 mhz, whichever is slower. when the spi is configured as a sl ave, the maximum data transfer rate (bits/sec) for full-duplex operation is 1/10 the system clock frequency , provided that the master issues sck, nss (in 4- wire slave mode), and the serial input data synchrono usly with the slave?s system clock. if the master issues sck, nss, and the serial input data asynchronously, the maximum data transfer rate (bits/sec) must be less than 1/10 the system clock frequency. in the special case where the master only wants to transmit data to the slave and does not need to receive data from the slave (i.e. half-duplex operation), the spi slave can receive data at a maximum data transfer rate (bits/sec) of 1/4 the system clock frequency. this is provided that the master i ssues sck, nss, and the serial inpu t data synchronously with the slave?s system clock. figure 16.5. data/clock timing relationship 16.6. spi special function registers spi0 is accessed and controlled through four special function registers in the system controller: spi0cn control register, spi0dat data re gister, spi0cfg configuration register, and spi0ckr clock rate register. the four special function registers related to the operation of the spi0 bus are described in the following figures. sck (ckpol=0, ckpha=0) sck (ckpol=0, ckpha=1) sck (ckpol=1, ckpha=0) sck (ckpol=1, ckpha=1) msb bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 miso/mosi
rev. 1.4 157 c8051f52x/f53x sfr definition 16.1. spi0c fg: spi0 configuration bit 7: spibsy : spi busy (read only). this bit is set to logic 1 when a spi transfer is in progress (master or slave mode). bit 6: msten : master mode enable. 0: disable master mode. operate in slave mode. 1: enable master mode. operate as a master. bit 5: ckpha : spi0 clock phase. this bit controls the spi0 clock phase. 0: data centered on first edge of sck period.* 1: data centered on second edge of sck period.* bit 4: ckpol : spi0 clock polarity. this bit controls the spi0 clock polarity. 0: sck line low in idle state. 1: sck line high in idle state. bit 3: slvsel : slave selected flag (read only). this bit is set to logic 1 whenever the nss pin is low indicating spi0 is the selected slave. it is cleared to logic 0 when nss is high (slave not selected). this bit does not indicate the instantaneous value at the nss pin, but ra ther a de-glitched version of the pin input. bit 2: nssin : nss instantaneous pin input (read only). this bit mimics the instantaneous value that is present on the nss port pin at the time that the register is read. this input is not de-glitched. bit 1: srmt : shift register empty (valid in slave mode, read only). this bit will be set to logic 1 when all data has been transferred in/out of the shift register, and there is no new information available to read from the transmit buffer or write to the receive buffer. it returns to logic 0 when a data byte is transferred to the shift register from the transmit buffer or by a transition on sck. note: srmt = 1 when in master mode. bit 0: rxbmt : receive buffer empty (valid in slave mode, read only). this bit will be set to logic 1 when the receiv e buffer has be en read and contains no new information. if there is new information available in the receive buffer that has not been read, this bit will return to logic 0. note: rxbmt = 1 when in master mode. note: see table 16.1 for timing parameters. r r/w r/w r/w r r r r reset value spibsy msten ckpha ckpol slvsel nssin srmt rxbmt 00000111 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: 0xa1
c8051f52x/f53x 158 rev. 1.4 sfr definition 16.2. spi0cn: spi0 control bit7: spif : spi0 interrupt flag. this bit is set to logic 1 by hardware at the end of a data trans fer. if interrupts are enabled, setting this bit causes the cpu to vector to the spi0 interrupt service routine. this bit is not automatically cleared by hardware. it must be cleared by software. bit6: wcol : write collision flag. this bit is set to logic 1 by hardware (and gener ates a spi0 interrupt) if a write to spi0dat is attempted when the transmit buffer has not been emptied to the spi shift register. when this occurs, the write to spi0dat will be ignored, and the transmit bu ffer will not be written. this bit is not automatically cleared by hardware. it must be cleared by software. bit5: modf : mode fault flag. this bit is set to logic 1 by hardware (and ge nerates a spi0 interrupt) when a master mode collision is detected (nss is low, msten = 1, and nssmd[1:0] = 01). this bit is not auto- matically cleared by hardware. it must be cleared by software. bit4: rxovrn : receive overrun flag (slave mode only). this bit is set to logic 1 by hardware (and ge nerates a spi0 interrupt) when the receive buf- fer still holds unread data from a previous transfer and the last bit of the current transfer is shifted into the spi0 shift register. this bit is not automatically cleare d by hardware. it must be cleared by software. bits3?2 : nssmd1?nssmd0 : slave select mode. selects between the following nss operation modes: (see section ?16.2. spi0 master mode operatio n? on page 153 and section ?16.3. spi0 slave mode operation? on page 154). 00: 3-wire slave or 3-wire master mode. nss signal is not routed to a port pin. 01: 4-wire slave or multi-master mode (defau lt). nss is always an input to the device. 1x: 4-wire single-master mode. nss signal is mapped as an ou tput from the device and will assume the value of nssmd0. bit1: txbmt : transmit buffer empty. this bit will be set to logic 0 when new data ha s been written to the transmit buffer. when data in the transmit buffer is tr ansferred to the spi sh ift register, this bit will be set to logic 1, indicating that it is safe to writ e a new byte to the transmit buffer. bit0: spien : spi0 enable. this bit enables/disables the spi. 0: spi disabled. 1: spi enabled. r/w r/w r/w r/w r/w r/w r r/w reset value spif wcol modf rxovrn nssmd1 nssmd0 txbmt spien 00000110 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit addressable sfr address: 0xf8
rev. 1.4 159 c8051f52x/f53x sfr definition 16.3. spi 0ckr: spi0 clock rate bits7?0 : scr7?scr0 : spi0 clock rate. these bits determine the frequency of the sck output when the spi0 module is configured for master mode operation. the sck clock frequ ency is a divided version of the system clock, and is given in th e following equation, where sysclk is the system clock frequency and spi0ckr is the 8-bit value held in the spi0ckr register. for 0 <= spi0ckr <= 255 example: if sysclk = 2 mhz and spi0ckr = 0x04, r/w r/w r/w r/w r/w r/w r/w r/w reset value scr7 scr6 scr5 scr4 scr3 scr2 scr1 scr0 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: 0xa2 f sck sysclk 2 spi 0 ckr 1+ ?? ? --------------------------------- --------------- - = f sck 2000000 241 + ?? ? -------------------------- = f sck 200 khz =
c8051f52x/f53x 160 rev. 1.4 sfr definition 16.4. spi0dat: spi0 data bits7?0 : spi0dat : spi0 transmit and receive data. the spi0dat register is used to transmit an d receive spi0 data. writing data to spi0dat places the data into the transmit buffer and initiates a transfer when in master mode. a read of spi0dat returns the contents of the receive buffer. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: 0xa3
rev. 1.4 161 c8051f52x/f53x figure 16.6. spi master timing (ckpha = 0) figure 16.7. spi master timing (ckpha = 1) sck* t mckh t mckl mosi t mis miso * sck is shown for ckpol = 0. sck is the opposite polarity for ckpol = 1. t mih sck* t mckh t mckl miso t mih mosi * sck is shown for ckpol = 0. sck is the opposite polarity for ckpol = 1. t mis
c8051f52x/f53x 162 rev. 1.4 figure 16.8. spi slave timing (ckpha = 0) figure 16.9. spi slave timing (ckpha = 1) sck* t se nss t ckh t ckl mosi t sis t sih miso t sd t soh * sck is shown for ckpol = 0. sck is the opposite polarity for ckpol = 1. t sez t sdz sck* t se nss t ckh t ckl mosi t sis t sih miso t sd t soh * sck is shown for ckpol = 0. sck is the opposite polarity for ckpol = 1. t sez t sdz
rev. 1.4 163 c8051f52x/f53x table 16.1. spi slave timing parameters parameter description min max units master mode timing* (see figure 16.6 and figure 16.7) t mckh sck high time 1 x t sysclk ?ns t mckl sck low time 1 x t sysclk ?ns t mis miso valid to sck sample edge 20 ? ns t mih sck sample edge to miso change 0 ? ns slave mode timing* (see figure 16.8 and figure 16.9) t se nss falling to first sck edge 2 x t sysclk ?ns t sd last sck edge to nss rising 2 x t sysclk ?ns t sez nss falling to miso valid ? 4 x t sysclk ns t sdz nss rising to miso high-z ? 4 x t sysclk ns t ckh sck high time 5 x t sysclk ?ns t ckl sck low time 5 x t sysclk ?ns t sis mosi valid to sck sample edge 2 x t sysclk ?ns t sih sck sample edge to mosi change 2 x t sysclk ?ns t soh sck shift edge to miso change ? 4 x t sysclk ns note: t sysclk is equal to one period of the de vice system clock (sysclk) in ns. ? the maximum possible frequency of the spi can be calculated as: ? transmission: sysclk/2 ? reception: sysclk/10
c8051f52x/f53x 164 rev. 1.4 17. lin (c8051f520/0a/3/3a/6/6 a and c8051f530/0a/3/3a/6/6a) important note: this chapter assumes an understanding of the local interconnect network (lin) proto- col. for more information about the lin protocol, including specifications, please refer to the lin consor- tium (http://www.lin-subbus.org/). lin is an asynchronous, serial co mmunications interface us ed primarily in automotive networks. the sili- con laboratories lin controller is compliant to the 2. 1 specification, implements a complete hardware lin interface, and includes the following features: ? selectable master and slave modes. ? automatic baud rate option in slave mode ? the internal oscillator is accurate to within 0.5% of 24.5 mhz acro ss the entire temperature range and for vdd voltages greater than or equal to the minimum output of the on-chip voltage regulator, so an external oscillator is not necessary for mast er mode operation for most systems. note: the minimum system clock (sysclk) required when using the lin peripheral is 8 mhz. figure 17.1. lin block diagram the lin peripheral has four main components: 1. lin access registers?provide the interface between the mcu core and the lin peripheral. 2. lin data registers?where transmitted and received message data bytes are stored. 3. lin control registers?control the functionality of the lin interface. 4. control state machine and bit streaming logic?contains the hardware that serializes mes - sages and controls the bus timing of the controller.  c8051f520/0a/3/3a/6/6a and c8051f530/0a/3/3a/6/6a indirectly addressed registers linaddr lindata lincf lin data registers control state machine 8051 mcu core tx rx lin controller lin control registers
rev. 1.4 165 c8051f52x/f53x 17.1. software interfa ce with the lin peripheral the selection of the mode (master or slave) and the automatic baud rate feature are done though the lin0 control mode (lin0cf) register. the other lin regist ers are accessed indirectly through the two sfrs lin0 address (linaddr) and lin0 da ta (lindata). the linaddr register selects which lin register is targeted by reads/writes of the lindata register. the full list of indirectly-accessible lin register is given in table 17.4 on page 174. 17.2. lin interface setup and operation the hardware based lin peripheral allows for the implementation of both master and slave nodes with minimal firmware overhead and complete control of t he interface status while allowing for interrupt and polled mode operation. the first step to use the peripheral is to de fine the basic characteristics of the node: ? mode?master or slave ? baud rate?either defined manually or using the autobaud feature (slave mode only). ? checksum type?select between classic or enhanced checksum, both of which are implemented in hardware. 17.2.1. mode definition following the lin specification, the peripheral implements both the slave and master operating modes in hardware. the mode is configured using the mode bit (lin0cf.6). 17.2.2. baud rate options: manual or autobaud the lin peripheral can be selected to have its baud rate calculated manually or automatically. a master node must always have its baud rate set manually, but slave nodes can choose between a manual or auto- matic setup. the configur ation is selected using the abaud bit (lin0cf.5). both the manual and automatic baud rate configurati ons require additional setup. the following sections explain the different options available and their relati on with the baud rate, along with the steps necessary to achieve the required baud rate. 17.2.3. baud rate calculations?manual mode the baud rate used by the peripher al is a function of the system clo ck (sysclk) and the bit-timing reg- isters according to the following equation: the prescaler, divider and multiplier factors are pa rt of the lin0div and lin0mul registers and can assume values in the following range: baud_ rate sysclk 2 prescaler 1 + divider multiplier 1+ uu ------------------------------------------------------------------------------------------------------ - =
c8051f52x/f53x 166 rev. 1.4 important : the minimum system clock (sysclk) to operate the lin peri pheral is 8 mhz. use the following equations to calculate the values for the variables for the baud-rate equation: it is important to note that in all these equations, t he results must be rounded down to the nearest integer. the following example shows the steps for calculating th e baud rate values for a master node running at 24.5 mhz and communicating at 19200 bits/sec. first, calculate the multiplier: next, calculate the prescaler: finally, calculate the divider: these values lead to the following baud rate: table 17.1. baud-rate calculation variable ranges factor range prescaler 0?3 multiplier 0?31 divider 200?511 multiplier 20000 baud _ rate --------------- ------------ 1? = prescaler ln sysclk multiplier 1+ ?? baud _ rate 200 ? ? -------------------------------------------------------------------------- --------------- - 1 ln 2 ------- - 1? ? = divider sysclk 2 prescaler 1 + ?? multiplier 1+ ?? ? baud _ rate ? ?? ------------------------------------------------------------------------------------------------------------------- - = multiplier 20000 19200 -------------- - 1 0.0417 0 ? =?= prescaler ln 24500000 01 + ?? 19200 200 ?? ----------------------------------------------------- 1 ln 2 ------- - 1? ? 1.674 =1 ? = divider 24500000 2 11 + ?? 01 + ?? ? 19200 ? ----------------------------------------- ------------------- - 319.010 319 ? == baud_ rate 24500000 2 11 + ?? 01 + ?? ? 319 ? -------------------------------------- ---------------- - 19200.63 ? =
rev. 1.4 167 c8051f52x/f53x the following code programs the interface in master mode, using the enhanced checksum and enables the interface to operate at 19200 bits /sec using a 24 mhz system clock. lin0cf = 0x80;// activate the interface lin0cf |= 0x40;// set the node as a master linaddr = 0x0d;// point to the lin0mul register // initialize the register (prescaler, multiplier and bit 8 of divider) lindata = ( 0x01 << 6 ) + ( 0x00 << 1 ) + ( ( 0x13f & 0x0100 ) >> 8 ); linaddr = 0x0c;// point to the lin0div register lindata = (unsigned char)_0x13f;// initialize lin0div linaddr = 0x0b;// point to the lin0size register lindata |= 0x80;// initialize the checksum as enhanced linaddr = 0x08;// point to lin0ctrl register lindata = 0x0c;// rese t any error and the interrupt table 17.2 includes the configuration values requ ired for the typical system clocks and baud rates: table 17.2. manual baud rate parameters examples baud (bits / sec) 20 k 19.2 k 9.6 k 4.8 k 1 k sysclk (mhz) mult. pres. div. mult. pres. div. mult. pres. div. mult. pres. div. mult. pres. div. 25 0 1 312 0 1 325 1 1 325 3 1 325 19 1 312 24.5 0 1 306 0 1 319 1 1 319 3 1 319 19 1 306 24 0 1 300 0 1 312 1 1 312 3 1 312 19 1 300 22.1184 0 1 276 0 1 288 1 1 288 3 1 288 19 1 276 16 0 1 200 0 1 208 1 1 208 3 1 208 19 1 200 12.25 0 0 306 0 0 319 1 0 319 3 0 319 19 0 306 12 0 0 300 0 0 312 1 0 312 3 0 312 19 0 300 11.0592 0 0 276 0 0 288 1 0 288 3 0 288 19 0 276 8 0 0 200 0 0 208 1 0 208 3 0 208 19 0 200
c8051f52x/f53x 168 rev. 1.4 17.2.4. baud rate calculations?automatic mode if the lin peripheral is configured for slave mode, on ly the prescaler and divider need to be calculated: the following example calculates the values of these variables for a 24 mhz system clock: table 17.3 presents some typical values of syst em clock and baud rate along with their factors. table 17.3. autobaud parameters examples system clock (mhz) prescaler divider 25 1 312 24.5 1 306 24 1 300 22.1184 1 276 16 1 200 12.25 0 306 12 0 300 11.0592 0 276 802 0 0 prescaler ln sysclk 4000000 ------------- -------- - 1 ln 2 ------- - 1? ? = divider sysclk 2 prescaler 1+ ?? 20000 ? ------------------------------------- ---------------- - = prescaler ln 24500000 4000000 ----------------------- - 1 ln 2 ------- - 1? ? 1.615 =1 ? = divider 24500000 2 11 + ?? 20000 ? ------------------------------------ - 306.25 306 ? ==
rev. 1.4 169 c8051f52x/f53x 17.3. lin master mode operation the master node is responsible for the scheduling of messages and sends the header of each frame, con- taining the synch break field, synch field and id entifier field. the steps to schedule a mes- sage transmission or reception are listed below. 1. load the 6-bit identifier into the lin0id register. 2. load the data length into the lin0size register. set the value to the number of data bytes or "1111b" if the data length should be decoded from the identifier. also, set the checksum type, classic or enhanced, in the same lin0size register. 3. set the data direction by setting the txrx bit (l in0ctrl.5). set the bit to 1 to perform a master transmit operation, or set the bit to 0 to perform a master receive operation. 4. if performing a master transmit operation, load the data bytes to transmit into the data buffer (lin0dt1 to lin0dt8). 5. set the streq bit (lin0ctrl.0) to start the me ssage transfer. the lin pe ripheral will schedule the message frame and request an interrupt if the message transfer is successfully co mpleted or if an error has occurred. this code segment shows the procedure to schedule a message in a transmission operation: linaddr = 0x08;// point to lin0ctrl lindata |= 0x20;// select to transmit data linaddr = 0x0e;// point to lin0id lindata = 0x11;// load the id, in this example 0x11 linaddr = 0x0b;// point to lin0size lindata = ( lindata & 0xf0 ) | 0x08; // load the size with 8 linaddr = 0x00;// point to data buffer first byte for (i=0; i<8; i++) { lindata = i + 0x41;// load the buffer with ?a?, ?b?, ... linaddr++;// increment the address to the next buffer } linaddr = 0x08;// point to lin0ctrl lindata = 0x01;// start request the application should perform the following steps when an interrupt is requested. 1. check the done bit (lin0st.0) and the error bit (lin0st.2). 2. if performing a master receive operation and the transfer was successful, read the received data from the data buffer. 3. if the transfer was not succe ssful, check the error register to determine the kind of error. further error handling has to be done by the application. 4. set the rstint (lin0ctrl.3) and rsterr bits (l in0ctrl.2) to reset the interrupt request and the error flags.
c8051f52x/f53x 170 rev. 1.4 17.4. lin slave mode operation when the device is configured for slave mode operati on, it must wait for a command from a master node. access from the firmwa re to data buffer and id registers of the lin peripheral is only possible when a data request is pending (dtreq bit (lin0st.4) is 1) and also when the lin bus is not active (active bit (lin0st.7) is set to 0). the lin peripheral in slave mode detects the header of the message frame sent by the lin master. if slave synchronization is enabled (autobaud), the slave synchron izes its internal bit time to the master bit time. the lin peripheral configur ed for slave mode will generated an in terrupt in one of three situations: 1. after the reception of the identifier field. 2. when an error is detected. 3. when the message transfer is completed. ? the application should perform the following steps when an interrupt is detected: 1. check the status of the dtreq bit (lin0st.4). this bit is set when the identifier field has been received. 2. if dtreq (lin0st.4) is set, read the identifier from lin0id and process it. if dtreq (lin0st.4) is not set, continue to step 7. 3. set the txrx bit (lin0ctrl.5) to 1 if the current frame is a transmit operation for the slave and set to 0 if the current frame is a receive operation for the slave. 4. load the data length into lin0size. 5. for a slave transmit operation, load the data to transmit into the data buffer. 6. set the dtack bit (lin0ctrl.4). continue to step 10. 7. if dtreq (lin0st.4) is not set, ch eck the done bit (lin0st.0). the tr ansmission was successful if the done bit is set. 8. if the transmission was su ccessful and the current frame was a receive operation for the slave, load the received data bytes from the data buffer. 9. if the transmission was not successful, check lin0e rr to determine the nature of the error. further error handling has to be done by the application. 10.set the rstint (lin0ctrl.3) a nd rsterr bits (lin0ctrl.2) to re set the interrupt request and the error flags. ? in addition to these steps, the app lication should be aware of the following: 1. if the current frame is a transmit operation for the slave, steps 1 through 5 must be completed during the in-frame response space. if it is not completed in time, a timeout will be detected by the master. 2. if the current frame is a receive operation for the slav e, steps 1 through 5 have to be finished until the reception of the first byte after the identifier field. otherwise, the internal receive buffer of the lin peripheral will be overwritten and a timeout er ror will be detected in the lin peripheral. 3. the lin module does not directly support lin vers ion 1.3 extended frames. if the application detects an unknown identifier (e.g. extended identifier), it has to write a 1 to the stop bit (lin0ctrl.7) instead of setting the dtack (lin0ctrl.4) bit. at that ti me, steps 2 through 5 can then be skipped. in this situation, the lin peripheral stops the processi ng of the lin communication until the next sync break is received. 4. changing the configuration of t he checksum during a transaction will cause the in terface to reset and the transaction to be lost. to prevent this, the checksum should not be configured while a transaction is
rev. 1.4 171 c8051f52x/f53x in progress. the same applies to changes in the lin interface mode from slave mode to master mode and from master mode to slave mode. 17.5. sleep mode and wake-up to reduce the system?s power consumption, the li n protocol specification defines a sleep mode. the message used to broadcast a sleep mode request mu st be transmitted by the lin master application in the same way as a normal transmit message. the lin slave application must decode the sleep mode frame from the identifier and data bytes. after that, the lin slave node must be put into the sleep mode by setting the sleep bit (lin0ctrl.6). if the sleep bit (lin0ctrl.6) of the lin slave application is not set and there is no bus activity for four seconds (specified bus idle timeout), the idltout bit (lin0st.6) is set and an interrupt request is gener- ated. after that the application may assume that the lin bus is in sleep mode and set the sleep bit (lin0ctrl.6). sending a wakeup signal from the master or any sl ave node terminates the sleep mode of the lin bus. to send a wakeup signal, the application has to set th e wupreq bit (lin0ctrl.1). after successful trans- mission of the wakeup signal, the done bit (lin0st.0) of the master node is set and an interrupt request is generated. the lin slave does not generate an inte rrupt request after successful transmission of the wakeup signal but it generates an interrupt request if the master does not respond to the wakeup signal within 150 milliseconds. in that case, the error bit (lin0st.2) and tout bit (lin0err.2) are set. the application then has to decide whether or not to transmit another wakeup signal. all lin nodes that detect a wakeup signal will set the wakeup (lin0st.1) and done bits (lin0st.0) and generate an interrupt request. afte r that, the application has to clear the sleep bit (lin0ctrl.6) in the lin slave. 17.6. error det ection and handling the lin peripheral generates an interrupt request and stops the processing of the current frame if it detects an error. the application has to check the type of error by processing lin0err. after that, it has to reset the error register and the error bit (lin0st. 2) by writing a 1 to the rsterr bit (lin0ctrl.2). starting a new message with the lin peripheral selected as master or sending a wakeup signal with the lin peripheral selected as a master or slave is possible only if error bit (lin0st.2) is set to 0.
c8051f52x/f53x 172 rev. 1.4 17.7. lin registers the following special function r egisters (sfrs) are available: 17.7.1. lin direct access sfr registers definition sfr definition 17.1. linaddr: indirect address register sfr definition 17.2. lind ata: lin data register bit7?0: linaddr7-0 : lin indirect address register bits. this register hold an 8-bit address used to indirectly access the lin0 core registers. table 17.4 lists the lin0 core registers and t heir indirect addresses. reads and writes to lindata will target the register indicated by the linaddr bits. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: 0x92 bit7?0: lindata7-0 : lin indirect data register bits. when this register is read, it will read the contents of the lin0 core register pointed to by linaddr. when this register is wr itten, it will write the value to the li n0 core register pointed to by lin- addr. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: 0x93
rev. 1.4 173 c8051f52x/f53x sfr definition 17.3. linc f control mode register bit7: linen : lin interface enable bit 0: lin0 is disabled. 1: lin0 is enabled. bit6: mode : lin mode selection 0: lin0 operates in slave mode. 1: lin0 operates in master mode. bit5: abaud : lin mode automatic baud rate selection ( slave mode only ). 0: manual baud rate selection is enabled. 1: automatic baud rate selection is enabled. r/w r/w r/w r/w r/w r/w r/w r/w reset value linen mode abaud 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: 0x95
c8051f52x/f53x 174 rev. 1.4 17.7.2. lin indirect access sfr registers definition *these registers are used in both ma ster and slave mode. the register bi ts marked with (m) are accessible only in master mode while the register bits marked wi th (s) are accessible only in slave mode. all other reg- isters are accessible in both modes. sfr definition 17.4. lin0dt1: lin0 data byte 1 table 17.4. lin registers* (indirectly addressable) name address bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 lin0dt1 0x00 data1[7:0] lin0dt2 0x01 data2[7:0] lin0dt3 0x02 data3[7:0] lin0dt4 0x03 data4[7:0] lin0dt5 0x04 data5[7:0] lin0dt6 0x05 data6[7:0] lin0dt7 0x06 data7[7:0] lin0dt8 0x07 data8[7:0] lin0ctrl 0x08 stop(s) sl eep(s) txrx dtack(s) rstint rsterr wupreq streq(m) lin0st 0x09 active idltout abort(s ) dtreq(s) linint error wakeup done lin0err 0x0a synch(s) prty(s) tout chk biterr lin0size 0x0b enhchk linsize[3:0] lin0div 0x0c divlsb[7:0] lin0mul 0x0d prescl[1:0] linmul[4:0] div9 lin0id 0x0e id[5:0] bit7?0: lin0dt1 : lin data byte 1. serial data byte 1 that is received or transmitted across the lin interface. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 address: 0x00 (indi- rect)
rev. 1.4 175 c8051f52x/f53x sfr definition 17.5. lin0dt2: lin0 data byte 2 sfr definition 17.6. lin0dt3: lin0 data byte 3 sfr definition 17.7. lin0dt4: lin0 data byte 4 bit7?0: lin0dt2 : lin data byte 2. serial data byte 2 that is received or transmitted across the lin interface. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 address: 0x01 (indirect) bit7?0: lin0dt3 : lin data byte 3. serial data byte 3 that is received or transmitted across the lin interface. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 address: 0x02 (indirect) bit7?0: lin0dt4 : lin data byte 4. serial data byte 4 that is received or transmitted across the lin interface. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 address: 0x03 (indirect)
c8051f52x/f53x 176 rev. 1.4 sfr definition 17.8. lin0dt5: lin0 data byte 5 sfr definition 17.9. lin0dt6: lin0 data byte 6 sfr definition 17.10. lin0 dt7: lin0 data byte 7 sfr definition 17.11. lin0 dt8: lin0 data byte 8 bit7?0: lin0dt5 : lin data byte 5. serial data byte 5 that is received or transmitted across the lin interface. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 address: 0x04 (indirect) bit7?0: lin0dt6 : lin data byte 6. serial data byte 6 that is received or transmitted across the lin interface. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 address: 0x05 (indirect) bit7?0: lin0dt7 : lin data byte 7. serial data byte 7 that is received or transmitted across the lin interface. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 address: 0x06 (indirect) bit7?0: lin0dt8 : lin data byte 8. serial data byte 8 that is received or transmitted across the lin interface. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 address: 0x07 (indirect)
rev. 1.4 177 c8051f52x/f53x sfr definition 17.12. lin0ct rl: lin0 control register bit7: stop : stop communication processing bit ( slave mode only ). this bit is to be set by the application to block the processing of the lin communications until the next synch break signal. it is used when the application is handling a data request interrupt and cannot use the frame content with the received identifier (always reads 0). bit6: sleep : sleep mode warning. this bit is to be set by the application to warn the peripheral that a sleep mode frame was received and that the bus is in sleep mode or if a bus idle timeout interrupt is requested. the application must reset it when a wake-up interrupt is requested. bit5: txrx : transmit/receive selection bit. this bit determines if the current frame is a transmit frame or a receive frame. 0: current frame is a receive operation. 1: current frame is a transmit operation. bit4: dtack : data acknowledge bit ( slave mode only ). set to 1 after handling a data request interrupt to acknowledge the transfer. the bit will auto- matically be cleared to 0 by the lin controller. bit3: rstint : interrupt reset bit. this bit always reads as 0. 0: no effect. 1: reset the linint bit (lin0st.3). bit2: rsterr : error reset bit. this bit always reads as 0. 0: no effect. 1: reset the error bits in lin0st and lin0err. bit1: wupreq : wake-up request bit. set to 1 to terminate sleep m ode by sending a wakeup signal . the bit will automatically be cleared to 0 by the lin controller. bit0: streq : start request bit ( master mode only ). 1: start a lin transmission. this should be set only after loading the identifier, data length and data buffer if necessary. the bit is reset to 0 upon transmission completion or error detection. w w w r/w r/w r/w r/w r/w reset value stop sleep txrx dtack rstint rsterr wupreq streq 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 address: 0x08 (indirect)
c8051f52x/f53x 178 rev. 1.4 sfr definition 17.13. lin0 st: lin0 status register bit7: active : lin bus activity bit. 0: no transmission activity detected on the lin bus. 1: transmission activity detected on the lin bus. bit6: idltout : bus idle timeout bit ( slave mode only ). 0: the bus has not been idle for four seconds. 1: no bus activity has been detected for four seconds, but the bus is not yet in sleep mode. bit5: abort : aborted transmission signal ( slave mode only ). 0: the current transmission has not been interrupted or stopped. this bit is reset to 0 after receiving a synch break that does not interrupt a pending transmission. 1: new synch break detected before the end of the last transmission or the stop bit (lin0ctrl.7) has been set. bit4: dtreq : data request bit ( slave mode only ). 0: data identifier has not been received. 1: data identifier has been received. bit3: linint : interrupt request bit. 0: an interrupt is not pending. this bit is cleared by setting rstint (lin0ctrl.3) 1: there is a pending lin0 interrupt. bit2: error : communication error bit. 0: no error has been detected. this bit is cleared by setting rsterr (lin0ctrl.2) 1: an error has been detected. bit1: wakeup : wakeup bit. 0: a wakeup signal is not being transmitted and has not been received. 1: a wakeup signal is being transmitted or has been received. bit0: done : transmission complete bit. 0: a transmission is not in progress or has not been started. this bit is cleared at the start of a transmission. 1: the current transm ission is complete. rrrrr / wrr rr e s e t v a l u e active idltout abort dtre q linint error wakeup done 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 address: 0x09 (indirect)
rev. 1.4 179 c8051f52x/f53x sfr definition 17.14. lin0err: lin0 error register bits7?5 : unused . read = 000b. write = don?t care. bit4: synch : synchronization error bit ( slave mode only ). 0: no error with the synch field has been detected. 1: edges of the synch field are outside of the maximum tolerance. bit3: prty : parity error bit ( slave mode only ). 0: no parity error has been detected. 1: a parity error has been detected. bit2: tout : timeout error bit. 0: a timeout error has not been detected. 1: a timeout error has been detected. this er ror is detected whenever one of the following conditions is met: ?the master is expecting data from a slave and the slave does not respond. ?the slave is expecting data but no data is transmitted on the bus. ?a frame is not finished within the maximum frame length. ?the application does not set the dtack bit (lin 0ctrl.4) or stop bit (lin0ctrl.7) until the end of the reception of the first byte after the identifier. bit1: chk : checksum error bit. 0: checksum error ha s not been detected. 1: checksum error has been detected. bit0: biterr : bit transmission error bit. 0: no error in transmission has been detected. 1: the bit value monitored during transmissi on is different than the bit value sent. rrrrrrr rr e s e t v a l u e synch prty tout chk biterr 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 address: 0x0a (indirect)
c8051f52x/f53x 180 rev. 1.4 sfr definition 17.15. lin0size : lin0 message size register sfr definition 17.16. lin0di v: lin0 divider register bit7 : enhchk : checksum selection bit. 0: use the classic, specification 1.3 compliant checksum. checksum covers the data bytes. 1: use the enhanced, specification 2.1 compliant checksu m. checksum covers data bytes and protected identifier. bit6?4 : unused . read = 000b. write = don?t care. bit3?0 : linsize3?0 : data field size. 0000: 0 data bytes 0001: 1 data byte 0010: 2 data bytes 0011: 3 data bytes 0100: 4 data bytes 0101: 5 data bytes 0110: 6 data bytes 0111: 7 data bytes 1000: 8 data bytes 1001-1110: reserved 1111: use the id[1:0] bits (lin0id[5: 4]) to determine the data length. r/w r/w r/w r/w r/w r/w r/w r/w reset value enhchk - - - linsize[3:0] 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 address: 0x0b (indirect) bit7?0: divlsb[7:0] : lin baud rate divider least significant bits. the 8 least significant bits for the baud rate divider. the 9th and most significant bit is the div9 bit (lin0mul.0). the valid range for the divider is 200 to 511. rrrrrrr rr e s e t v a l u e 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 address: 0x0c (indirect)
rev. 1.4 181 c8051f52x/f53x sfr definition 17.17. lin0mul: lin0 multiplier register sfr definition 17.18. lin0id: lin0 id register bit7?6: prescl1?0 : lin baud rate prescaler bits. these bits are the baud rate prescaler bits. bit5?1: linmul4?0 : lin baud rate multiplier bits. these bits are the baud rate multiplier bits. these bits are not used in slave mode. bit0: div9 : lin baud rate divider most significant bit. the most significant bit of the baud rate divide r. the 8 least significant bits are in lin0div. the valid range for the divider is 200 to 511. r/w r/w r/w r/w r/w r/w r/w r/w reset value prescl[1:0] linmul[4:0] div9 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 address: 0x0d (indirect) bit7?6: unused . read = 00b. write = don?t care. bit5?0: id5?0 : lin identifier bits. these bits form the data identifier. if the linsize bits (lin0size[3:0]) are 1111b, bits id[5:4] are used to determine the data size and are interpreted as follows: 00: 2 bytes 01: 2 bytes 10: 4 bytes 11: 8 bytes r/w r/w r/w r/w r/w r/w r/w r/w reset value id[5:0] 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 address: 0x0e (indirect)
c8051f52x/f53x 182 rev. 1.4 18. timers each mcu includes three counter/timers: two are 16-bit counter/timers compatible with those found in the standard 8051, and one is a 16-bit auto-reload timer for use with other device peripherals or for general purpose use. these timers can be used to measure ti me intervals, count external events and generate periodic interrupt requests. timer 0 and timer 1 are ne arly identical and have four primary modes of oper- ation. timer 2 offer 16-bit and split 8-bit timer functionality with auto-reload. timers 0 and 1 may be clocked by one of five sources, determined by the timer mode select bits (t1m ? t0m) and the clock scale bits (sca1 ? sca0). the clock scale bits define a pre-scaled clock from which timer 0 and/or timer 1 may be clocked (see sfr definition 18.3 for pre-scaled clock selection). timer 0/1 may then be configured to use this pre-sc aled clock signal or the s ystem clock. timer 2 may be clocked by the system clock, the system clock divided by 12, or the external oscillator clock source divided by 8. timer 0 and timer 1 may also be operated as counte rs. when functioning as a counter, a counter/timer register is incremented on each high-to-low transition at the selected input pin (t0 or t1). events with a fre- quency of up to one-fourth the system clock's frequency can be counted. the input signal need not be peri- odic, but it must be held at a gi ven level for at least two full system clock cycles to ensure the level is properly sampled. 18.1. timer 0 and timer 1 each timer is implemented as a 16-bit register acce ssed as two separate bytes: a low byte (tl0 or tl1) and a high byte (th0 or th1). the counter/timer co ntrol register (tcon) is used to enable timer 0 and timer 1 as well as indicate status. timer 0 interrupts ca n be enabled by setting the et0 bit in the ie register (section ?10.4. interrupt register descriptions? on page 100); timer 1 interrupts can be enabled by setting the et1 bit in the ie register (section 10.4). both counter/timers operate in one of four primary modes selected by setting the mode select bits t1m1 ? t0m0 in the counter/timer mode register (tmod). each timer can be configured independently. each operating mode is described below. 18.1.1. mode 0: 13 -bit counter/timer timer 0 and timer 1 operate as 13-bit counter/timers in mode 0. the following describes the configuration and operation of timer 0. however, both timers operat e identically, and timer 1 is configured in the same manner as described for timer 0. the th0 register holds the eight msbs of the 13-bit c ounter/timer. tl0 holds the five lsbs in bit positions tl0.4 ? tl0.0. the three upper bits of tl0 (tl0.7 ? tl0.5) are indeterminate and should be masked out or ignored when reading. as the 13-bit timer register increments and overflows from 0x1fff (all ones) to 0x0000, the timer overflow flag tf 0 (tcon.5) is set and an interrupt will occur if timer 0 interrupts are enabled. the c/t0 bit (tmod.2) selects the counter/timer's cloc k source. when c/t0 is set to logic 1, high-to-low transitions at the selected timer 0 input pin (t0) increment the timer register (refer to section ?13.1. priority crossbar decoder? on page 122 for information on selecting and configuring external i/o pins). clearing c/t selects the clock defined by the t0m bit (ckcon.3). when t0m is set, timer 0 is timer 0 and timer 1 modes timer 2 modes 13-bit counter/timer 16-bit timer with auto-reload 16-bit counter/timer 8-bit counter/timer with auto-reload two 8-bit timers with auto-reload two 8-bit counter/timers (timer 0 only)
rev. 1.4 183 c8051f52x/f53x clocked by the system clock. when t0m is cleared, timer 0 is clocked by the source selected by the clock scale bits in ckcon (see sfr definition 18.3). setting the tr0 bit (tcon.4) enables the timer when ei ther gate0 (tmod.3) is logic 0 or the input signal int0 is active as defined by bit in0pl in register it01cf (see sfr definition 10.5. it01cf: int0/int1 configuration). setting gate0 to 1 allows the timer to be controlled by the external input signal int0 (see section ?10.4. in terrupt register desc riptions? on page 100), facilitating pulse width measurements. setting tr0 does not force the timer to reset. the timer registers should be loaded with the desired initial value before the timer is enabled. tl1 and th1 form the 13-bit register for timer 1 in the same manner as described above for tl0 and th0. timer 1 is configured and controlled using the relevant tcon and tmod bits just as with timer 0. the input signal int0 is used with timer 1; the int0 polarity is defined by bit in1pl in register it01cf (see sfr definition 10.5. it01cf: int0/int1 configuration). figure 18.1. t0 mode 0 block diagram tr0 gate0 int0 counter/timer 0 x x disabled 1 0 x enabled 1 1 0 disabled 111enabled x = don't care it01cf
c8051f52x/f53x 184 rev. 1.4 18.1.2. mode 1: 16 -bit counter/timer mode 1 operation is the same as mode 0, except that the counter/timer registers use all 16 bits. the coun- ter/timers are enabled and configured in mode 1 in the same manner as for mode 0. 18.1.3. mode 2: 8-bit counter/timer with auto-reload mode 2 configures timer 0 and timer 1 to operate as 8-bit counter/timers with automatic reload of the start value. tl0 holds the count and th0 holds the reload va lue. when the counter in tl0 overflows from all ones to 0x00, the timer over flow flag tf0 (tcon.5) is set and the counter in tl0 is reloaded from th0. if timer 0 interrupts are enable d, an interrupt will occur when the tf0 flag is set. the reload va lue in th0 is not changed. tl0 must be initialized to the desired va lue before enabling the timer for the first count to be correct. when in mode 2, timer 1 operates identically to timer 0. both counter/timers are enabled and configured in mode 2 in the same manner as mode 0. setting the tr0 bit (tcon.4) enables the timer when either gate0 (tmod.3) is logic 0 or when the input signal int0 is active as defined by bit in0pl in register it01cf (s ee section ?10.5. external interrupts? on page 104 for details on the external input signals int0 and int0 ). figure 18.2. t0 mode 2 block diagram tclk tmod t 1 m 1 t 1 m 0 c / t 1 g a t e 1 g a t e 0 c / t 0 t 0 m 1 t 0 m 0 tcon tf0 tr0 tr1 tf1 ie1 it1 ie0 it0 interrupt tl0 (8 bits) reload th0 (8 bits) 0 1 0 1 sysclk pre-scaled clock int01cf i n 1 s l 1 i n 1 s l 0 i n 1 s l 2 i n 1 p l i n 0 p l i n 0 s l 2 i n 0 s l 1 i n 0 s l 0 tr0 gate0 in0pl xor /int0 t0 crossbar ckcon s c a 0 s c a 1 t 0 m t 2 m h t 2 m l t 1 m
rev. 1.4 185 c8051f52x/f53x 18.1.4. mode 3: two 8-bit counter/timers (timer 0 only) in mode 3, timer 0 is configured as two separate 8-bit counter/timers held in tl0 and th0. the coun- ter/timer in tl0 is controlled using the timer 0 contro l/status bits in tcon and tmod: tr0, c/t0, gate0 and tf0. tl0 can use either the system clock or an ex ternal input signal as its timebase. the th0 register is restricted to a timer function so urced by the system clock or presca led clock. th0 is enabled using the timer 1 run control bit tr1. th0 sets the timer 1 over flow flag tf1 on overflow and thus controls the timer 1 interrupt. timer 1 is inactive in mode 3. when timer 0 is operat ing in mode 3, timer 1 can be operated in modes 0, 1 or 2, but cannot be clocked by external signals nor set the tf1 flag and generate an interrupt. however, the timer 1 overflow can be used to generate baud rates for the smbus and uart. while timer 0 is oper- ating in mode 3, timer 1 run control is handled through its mode settings. to run timer 1 while timer 0 is in mode 3, set the timer 1 mode as 0, 1, or 2. to disable timer 1, configure it for mode 3. figure 18.3. t0 mode 3 block diagram tl0 (8 bits) tmod 0 1 tcon tf0 tr0 tr1 tf1 ie1 it1 ie0 it0 interrupt interrupt 0 1 sysclk pre-scaled clock tr1 th0 (8 bits) t 1 m 1 t 1 m 0 c / t 1 g a t e 1 g a t e 0 c / t 0 t 0 m 1 t 0 m 0 tr0 gate0 in0pl xor /int0 t0 crossbar ckcon t 3 m h t 3 m l s c a 0 s c a 1 t 0 m t 2 m h t 2 m l t 1 m
c8051f52x/f53x 186 rev. 1.4 sfr definition 18.1. tcon: timer control bit7 : tf1 : timer 1 overflow flag. set by hardware when timer 1 overflows. this flag can be cleared by software but is auto- matically cleared when the cpu vectors to the timer 1 interrupt service routine. 0: no timer 1 overflow detected. 1: timer 1 has overflowed. bit6 : tr1 : timer 1 run control. 0: timer 1 disabled. 1: timer 1 enabled. bit5 : tf0 : timer 0 overflow flag. set by hardware when timer 0 overflows. this flag can be cleared by software but is auto- matically cleared when the cpu vectors to the timer 0 interrupt service routine. 0: no timer 0 overflow detected. 1: timer 0 has overflowed. bit4 : tr0 : timer 0 run control. 0: timer 0 disabled. 1: timer 0 enabled. bit3 : ie1 : external interrupt 1. this flag is set by hardware when an edge/level of type defined by it1 is detected. it can be cleared by software but is automatically cleared when the cpu vectors to the external inter- rupt 1 service routine if it1 = 1. when it1 = 0, this flag is set to 1 when int0 is active as defined by bit in1pl in register it01cf (see sfr definition 10.5. ?it01cf: int0/int1 con- figuration? on page 105). bit2 : it1 : interrupt 1 type select. this bit selects whether the configured int0 interrupt will be edge or level sensitive. int0 is configured active low or high by the in 1pl bit in the it01cf register (see sfr definition 10.5. ?it01cf: int0/int1 configuration? on page 105). 0: int0 is level triggered. 1: int0 is edge triggered. bit1 : ie0 : external interrupt 0. this flag is set by hardware when an edge/level of type defined by it0 is detected. it can be cleared by software but is automatically cleared when the cpu vectors to the external inter- rupt 0 service routine if it0 = 1. when it0 = 0, this flag is set to 1 when int0 is active as defined by bit in0pl in register it01cf (see sfr definition 10.5. ?it01cf: int0/int1 con- figuration? on page 105). bit0 : it0 : interrupt 0 type select. this bit selects whether the configured int0 interrupt will be edge or level sensitive. int0 is configured active low or high by the in0pl bi t in register it01cf (s ee sfr definition 10.5. ?it01cf: int0/int1 configuration? on page 105). 0: int0 is level triggered. 1: int0 is edge triggered. r/w r/w r/w r/w r/w r/w r/w r/w reset value tf1 tr1 tf0 tr0 ie1 it1 ie0 it0 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit addressable sfr address: 0x88
rev. 1.4 187 c8051f52x/f53x sfr definition 18.2. tmod: timer mode bit7: gate1 : timer 1 gate control. 0: timer 1 enabled when tr1 = 1 irrespective of int0 logic level. 1: timer 1 enabled only when tr1 = 1 and int0 is active as defined by bit in1pl in register it01cf (see sfr definition 10.5. ?it01c f: int0/int1 configuration? on page 105). bit6: c/t1 : counter/timer 1 select. 0: timer function: timer 1 incremented by clock defined by t1m bit (ckcon.4). 1: counter function: timer 1 incremented by high-to-low transitions on external input pin (t1). bits5?4 : t1m1?t1m0 : timer 1 mode select. these bits select the timer 1 operation mode. bit3: gate0 : timer 0 gate control. 0: timer 0 enabled when tr0 = 1 irrespective of int0 logic level. 1: timer 0 enabled only when tr0 = 1 and int0 is active as defined by bit in0pl in register it01cf (see sfr definition 10.5. ?it01c f: int0/int1 configuration? on page 105). bit2: c/t0 : counter/timer select. 0: timer function: timer 0 incremented by clock defined by t0m bit (ckcon.3). 1: counter function: timer 0 incremented by high-to-low transitions on external input pin (t0). bits1?0 : t0m1?t0m0 : timer 0 mode select. these bits select the timer 0 operation mode. r/w r/w r/w r/w r/w r/w r/w r/w reset value gate1 c/t1 t1m1 t1m0 gate0 c/t0 t0m1 t0m0 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: 0x89 t1m1 t1m0 mode 0 0 mode 0: 13-bit counter/timer 0 1 mode 1: 16-bit counter/timer 1 0 mode 2: 8-bit counter/timer with auto-reload 1 1 mode 3: timer 1 inactive t0m1 t0m0 mode 0 0 mode 0: 13-bit counter/timer 0 1 mode 1: 16-bit counter/timer 1 0 mode 2: 8-bit counter/timer with auto-reload 1 1 mode 3: two 8-bit counter/timers
c8051f52x/f53x 188 rev. 1.4 sfr definition 18.3. ckcon: clock control bit7?6: reserved . read = 0b; must write 0b. bit5 : t2mh : timer 2 high byte clock select. this bit selects the clock supplied to the timer 2 high byte if timer 2 is configured in split 8- bit timer mode. t2mh is ignored if timer 2 is in any other mode. 0: timer 2 high byte uses the clock defined by the t2xclk bit in tmr2cn. 1: timer 2 high byte uses the system clock. bit4 : t2ml : timer 2 low byte clock select. this bit selects the clock supplie d to timer 2. if timer 2 is c onfigured in split 8-bit timer mode, this bit selects the clock supplied to the lower 8-bit timer. 0: timer 2 low byte uses the clock defined by the t2xclk bit in tmr2cn. 1: timer 2 low byte uses the system clock. bit3 : t1m : timer 1 clock select. this select the clock source su pplied to timer 1. t1m is ignore d when c/t1 is set to logic 1. 0: timer 1 uses the clock defined by the prescale bits, sca1 ? sca0. 1: timer 1 uses the system clock. bit2 : t0m : timer 0 clock select. this bit selects the clock source supplied to timer 0. t0m is ignored when c/t0 is set to logic 1. 0: counter/timer 0 uses the clock defined by the prescale bits, sca1 ? sca0. 1: counter/timer 0 uses the system clock. bits1?0 : sca1?sca0 : timer 0/1 prescale bits. these bits control the division of the clock su pplied to timer 0 and timer 1 if configured to use prescaled clock inputs. r/w r/w r/w r/w r/w r/w r/w r/w reset value ? ? t2mh t2ml t1m t0m sca1 sca0 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: 0x8e sca1 sca0 prescaled clock 0 0 system clock divided by 12 0 1 system clock divided by 4 1 0 system clock divided by 48 1 1 external clock divided by 8 note: external clock divided by 8 is synchronized with the system clock.
rev. 1.4 189 c8051f52x/f53x sfr definition 18.4. tl0: timer 0 low byte sfr definition 18.5. tl1: timer 1 low byte sfr definition 18.6. th 0: timer 0 high byte sfr definition 18.7. th 1: timer 1 high byte bits 7?0 : tl0 : timer 0 low byte. the tl0 register is the low byte of the 16-bit timer 0. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: 0x8a bits 7?0 : tl1 : timer 1 low byte. the tl1 register is the low byte of the 16-bit timer 1. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: 0x8b bits 7?0 : th0 : timer 0 high byte. the th0 register is the high byte of the 16-bit timer 0. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: 0x8c bits 7?0 : th1 : timer 1 high byte. the th1 register is the high byte of the 16-bit timer 1. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: 0x8d
c8051f52x/f53x 190 rev. 1.4 18.2. timer 2 timer 2 is a 16-bit timer formed by two 8-bit sfrs: tmr2l (low byte) and tmr2h (high byte). timer 2 may operate in 16-bit auto-reload mode or (split) 8-bit auto-reload mode. the t2split bit (tmr2cn.3) defines the timer 2 operation mode. timer 2 can also be used in capture mode to measure the rtc0 clock fre- quency or the external oscillator clock frequency. timer 2 may be clocked by the system clock, the system clock divided by 12, or the external oscillator source divided by 8. the external oscillator source divided by 8 is sy nchronized with the system clock. 18.2.1. 16-bit time r with auto-reload when t2split (tmr2cn.3) is zero, timer 2 operates as a 16-bit timer with auto-reload. timer 2 can be clocked by sysclk, sysclk divided by 12, or the exte rnal oscillator clock source divided by 8. as the 16-bit timer register increments and overflows from 0xffff to 0x0000, the 16-bit value in the timer 2 reload registers (tmr2rlh and tmr2rll) is loaded in to the timer 2 register as shown in figure 18.4, and the timer 2 high byte overflow flag (tmr2cn.7) is set. if timer 2 interrupts are enabled (if ie.5 is set), an interrupt will be generat ed on each timer 2 overflow. additiona lly, if timer 2 inte rrupts are enabled and the tf2len bit is set (tmr2cn. 5), an interr upt will be generated each time the lower 8 bits (tmr2l) overflow from 0xff to 0x00. figure 18.4. timer 2 16-bit mode block diagram external clock / 8 sysclk / 12 sysclk tmr2l tmr2h tmr2rll tmr2rlh reload tclk 0 1 tr2 tmr2cn t2split tf2l tf2h t2xclk tr2 0 1 t2xclk interrupt tf2len tmr2l overflow ckcon t 3 m h t 3 m l s c a 0 s c a 1 t 0 m t 2 m h t 2 m l t 1 m
rev. 1.4 191 c8051f52x/f53x 18.2.2. 8-bit timers with auto-reload when t2split is set, timer 2 operates as two 8-bi t timers (tmr2h and tmr2l). both 8-bit timers oper- ate in auto-reload mode as shown in figure 18.5. tmr2rll holds the reload value for tmr2l; tmr2rlh holds the reload value for tmr2h. the tr2 bit in tmr2cn handles the run control for tmr2h. tmr2l is always running when configured for 8-bit mode. each 8-bit timer may be c onfigured to use sysclk, sysclk divided by 12, or the external oscillator clock source divided by 8. the timer 2 clock select bits (t2mh and t2ml in ckcon) select either sysclk or the clock defined by the timer 2 external cloc k select bit (t2xclk in tmr2cn), as follows: the tf2h bit is set when tmr2h overflows from 0xff to 0x00; the tf2l bit is set when tmr2l overflows from 0xff to 0x00. when timer 2 interrupts are enabled (ie.5), an interrupt is generated each time tmr2h overflows. if timer 2 interrupts are enabled and tf2len (tmr2cn.5) is set, an interrupt is gener- ated each time either tmr2l or tmr2h overflows. when tf2len is enabled, software must check the tf2h and tf2l flags to determine the source of the timer 2 interrupt. the tf2h and tf2l interrupt flags are not cleared by hardware and must be manually cleared by software. figure 18.5. timer 2 8-bit mode block diagram t2mh t2xclk tmr2h clock source t2ml t2xclk tmr2l clock source 0 0 sysclk / 12 0 0 sysclk / 12 0 1 external clock / 8 0 1 external clock / 8 1 x sysclk 1 x sysclk sysclk tclk 0 1 tr2 external clock / 8 sysclk / 12 0 1 t2xclk 1 0 tmr2h tmr2rlh reload reload tclk tmr2l tmr2rll interrupt tmr2cn t2split tf2len tf2l tf2h t2xclk tr2 ckcon t 3 m h t 3 m l s c a 0 s c a 1 t 0 m t 2 m h t 2 m l t 1 m
c8051f52x/f53x 192 rev. 1.4 18.2.3. external capture mode capture mode allows the ex ternal oscillator to be measured against the syste m clock. timer 2 can be clocked from the system clock, or the system clock divided by 12, depending on the t2ml (ckcon.4) and t2xclk bits. when a capture event is generated, the contents of timer 2 (tmr2h:tmr2l) are loaded into the timer 2 reload registers (tmr2rlh:tmr2rll) and the tf2h flag is set. a capture event is gener- ated by the falling edge of the clock source being measured, which is the external oscillator/8. by recording the difference between tw o successive timer capture values, the external oscillator frequency can be determined with respect to the timer 2 clock. the timer 2 clock should be much faster than the capture clock to achieve an accurate reading. timer 2 shou ld be in 16-bit auto-reload mode when using capture mode. for example, if t2ml = 1b and tf2cen = 1b, timer 2 will clock every sysclk and capture every external clock divided by 8. if the sysclk is 24.5 mhz and the difference between two successive captures is 5984, then the external clock frequency is: this mode allows software to deter mine the external oscillator frequency when an rc network or capacitor is used to generate the clock source. figure 18.6. timer 2 capture mode block diagram 24.5 mhz 5984 8 ? ?? ------------------------ 0.032754 mhz or 32.754 khz = tclk 0 1 tr2 tmr2h tmr2rlh tf2cen tmr2l tmr2rll interrupt tmr2cn tr2clk tf2cen tf2len tf2l tf2h t2xclk tr2 external osc. / 8 0 1 t2xclk sysclk external osc. / 8 sysclk / 12 capture ckcon t 3 m h t 3 m l s c a 0 s c a 1 t 0 m t 2 m h t 2 m l t 1 m
rev. 1.4 193 c8051f52x/f53x sfr definition 18.8. tm r2cn: timer 2 control bit7: tf2h : timer 2 high byte overflow flag. set by hardware when the timer 2 high byte ov erflows from 0xff to 0x00. in 16 bit mode, this will occur when timer 2 overflows from 0xff ff to 0x0000. when the timer 2 inte rrupt is enabled, setting this bit causes the cpu to vector to the timer 2 interrupt service routine. tf2h is not automatically cleared by hard ware and must be cleared by software. bit6: tf2l : timer 2 low byte overflow flag. set by hardware when the timer 2 low byte over flows from 0xff to 0x00. when this bit is set, an interrupt will be generated if tf2len is set and timer 2 interr upts are enabled. tf2l will set when the low byte overflows regardless of the timer 2 mode. this bit is not automat- ically cleared by hardware. bit5: tf2len : timer 2 low byte interrupt enable. this bit enables/disables timer 2 low byte in terrupts. if tf2len is set and timer 2 inter- rupts are enabled, an interrupt w ill be generated when the low byte of timer 2 overflows. this bit should be cleared when operating timer 2 in 16-bit mode. 0: timer 2 low byte interrupts disabled. 1: timer 2 low byte interrupts enabled. bit4: tf2cen . timer 2 capture enable. 0: timer 2 capture mode disabled. 1: timer 2 capture mode enabled. bit3: t2split : timer 2 split mode enable. when this bit is set, timer 2 operates as two 8-bit timers with auto-reload. 0: timer 2 operates in 16-bit auto-reload mode. 1: timer 2 operates as two 8-bit auto-reload timers. bit2: tr2 : timer 2 run control. this bit enables/disables timer 2. in 8-bit mode, this bit enables/disables tmr2h only; tmr2l is always enabled in this mode. 0: timer 2 disabled. 1: timer 2 enabled. bit1: unused . read = 0b. write = don't care. bit0: t2xclk : timer 2 external clock select. this bit selects the external cl ock source for timer 2. if timer 2 is in 8-bit mode, this bit selects the external o scillator clock source for both time r bytes. however, the timer 2 clock select bits (t2mh and t2ml in register ck con) may still be used to select between the external clock and the system clock for either timer. 0: timer 2 external clock selection is the system clock divided by 12. 1: timer 2 external clock selection is the external clock divided by 8. r/w r/w r/w r/w r/w r/w r/w r/w reset value tf2h tf2l tf2len tf2cen t2split tr2 ? t2xclk 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit addressable sfr address: 0xc8
c8051f52x/f53x 194 rev. 1.4 sfr definition 18.9. tmr2rll: ti mer 2 reload register low byte sfr definition 18.10. tmr2rlh: ti mer 2 reload register high byte sfr definition 18.11. tm r2l: timer 2 low byte sfr definition 18.12. tmr2h timer 2 high byte bits7?0 : tmr2rll : timer 2 reload register low byte. tmr2rll holds the low byte of the reload value for timer 2. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: 0xca bits7?0 : tmr2rlh : timer 2 reload register high byte. the tmr2rlh holds the high byte of the reload value for timer 2. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: 0xcb bits7?0 : tmr2l : timer 2 low byte. in 16-bit mode, the tmr2l register contains the low byte of the 16-bit timer 2. in 8-bit mode, tmr2l contains the 8-bit low byte timer value. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: 0xcc bits7?0 : tmr2h : timer 2 high byte. in 16-bit mode, the tmr2h register contains t he high byte of the 16-bit timer 2. in 8-bit mode, tmr2h contains the 8-bit high byte timer value. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: 0xcd
rev. 1.4 195 c8051f52x/f53x 19. programmable counter array (pca0) the programmable counter array (pca0) provides enhanced timer functionality while requiring less cpu intervention than the standard 8051 counter/timers. th e pca consists of a dedicated 16-bit counter/timer and three 16-bit capture/compare modules. each capt ure/compare module has its own associated i/o line (cexn) which is routed through the crossbar to port i/o when enabled (see section ?13.1. priority cross- bar decoder? on page 122 for details on configuring the crossbar). the counter/timer is driven by a pro- grammable timebase that can select between six sour ces: system clock, system clock divided by four, system clock divided by twelve, the external oscillator clock source divided by 8, timer 0 overflow, or an external clock signal on the eci input pin. each capture/compare module may be configured to operate independently in one of three modes: edge-triggered capture, software timer, high-speed output, fre- quency output, 8-bit pwm, or 16-bit pwm (each mode is described in secti on ?19.2. capture/compare modules? on page 197). the pca is configured and controlled through the system controller's special function registers. the pca block diagram is shown in figure 19.1 important note: the pca module 2 may be used as a watchdog timer (wdt), and is enabled in this mode following a system reset. access to certain pca registers is restricted while wdt mode is enabled . see section ?19.3. watchdog timer mode? on page 203 for details. figure 19.1. pca block diagram capture/compare module 1 capture/compare module 0 capture/compare module 2 cex1 eci crossbar cex2 cex0 port i/o 16-bit counter/timer pca clock mux sysclk/12 sysclk/4 timer 0 overflow eci sysclk external clock/8
c8051f52x/f53x 196 rev. 1.4 19.1. pca counter/timer the 16-bit pca counter/timer consists of two 8-bi t sfrs: pca0l and pca0h. pca0h is the high byte (msb) of the 16-bit counter/timer and pca0l is the lo w byte (lsb). reading pc a0l automatically latches the value of pca0h into a ?snapshot? register; the following pca0h read accesses this ?snapshot? register. reading the pca0l register first guarantees an accu rate reading of the entire 16-bit pca0 counter. reading pca0h or pca0l does not disturb the counte r operation. the cps2-cps0 bits in the pca0md register select the timebase for the counter/timer as shown in table 19.1. when the counter/timer overflows from 0xffff to 0x0 000, the counter overflow fl ag (cf) in pca0md is set to logic 1 and an interrupt request is generated if cf interrupts are enabled. setting the ecf bit in pca0md to logic 1 enables the cf flag to generate an interrupt request. the cf bit is not automatically cleared by hardware when the cpu vectors to the inte rrupt service routine, and must be cleared by soft- ware (note: pca0 interrupts must be globally enabled before cf interrupts are recognized. pca0 inter- rupts are globally enabled by setting the ea bit (ie.7) and the epca0 bit in eie1 to logic 1). clearing the cidl bit in the pca0md register a llows the pca to continue normal op eration while the cpu is in idle mode. figure 19.2. pca counter/timer block diagram table 19.1. pca timebase input options cps2 cps1 cps0 timebase 0 0 0 system clock divided by 12 0 0 1 system clock divided by 4 0 1 0 timer 0 overflow 0 1 1 high-to-low transitions on eci (ma x rate = system clock divided by 4) 1 0 0 system clock 1 0 1 external oscillator source divided by 8* note: external clock divided by 8 is synchronized with the system clock. pca0md c i d l w d t e e c f c p s 1 c p s 0 w d l c k c p s 2 idle 0 1 pca0h pca0l snapshot register to sfr bus overflow to pca interrupt system cf pca0l read to pca modules sysclk/12 sysclk/4 timer 0 overflow eci 000 001 010 011 100 101 sysclk external clock/8 pca0cn c f c r c c f 0 c c f 2 c c f 1
rev. 1.4 197 c8051f52x/f53x 19.2. capture/compare modules each module can be configured to operate independently in one of six operation modes: edge-triggered capture, software timer, high speed output, frequency output, 8-bit pulse width modulator, or 16-bit pulse width modulator. each module has special func tion registers (sfrs) asso ciated with it in the cip- 51 system controller. these registers are used to exchange data with a module and configure the module's mode of operation. table 19.2 summarizes the bit settings in the pca0cp mn registers used to select the pca capture/com- pare module?s operating modes. setting the eccfn bi t in a pca0cpmn register enables the module's ccfn interrupt. note that pca0 interrupts must be globally enabled before individual ccfn interrupts are recognized. pca0 interrupts are globally enabled by setting the ea bit and the epca0 bit to logic 1. see figure 19.3 for details on the pca interrupt configuration. figure 19.3. pca interrupt block diagram table 19.2. pca0cpm register settings for pca capture/compare modules pwm16 ecom capp capn mat tog pwm eccf operation mode x x 1 0 0 0 0 x capture triggered by positive edge on cexn x x 0 1 0 0 0 x capture triggered by negative edge on cexn x x 1 1 0 0 0 x capture triggered by transition on cexn x 1 0 0 1 0 0 x software timer x 1 0 0 1 1 0 x high speed output x 1 0 0 x 1 1 x frequency output 0 1 0 0 x 0 1 x 8-bit pulse width modulator 1 1 0 0 x 0 1 x 16-bit pulse width modulator x = don?t care pca0cn c f c r c c f 0 c c f 2 c c f 1 pca0md c i d l e c f c p s 1 c p s 0 c p s 2 0 1 pca module 0 (ccf0) pca module 1 (ccf1) eccf1 0 1 eccf0 0 1 pca module 2 (ccf2) eccf2 pca counter/ timer overflow 0 1 interrupt priority decoder epca0 (eie1.4) pca0cpmn (for n = 0 to 5) p w m 1 6 n e c o m n e c c f n t o g n p w m n c a p p n c a p n n m a t n 0 1 ea (ie.7) 0 1
c8051f52x/f53x 198 rev. 1.4 19.2.1. edge-triggered capture mode in this mode, a valid transition on the cexn pin ca uses the pca to capture the value of the pca coun- ter/timer and load it into the corresponding module 's 16-bit capture/compar e register (pca0cpln and pca0cphn). the cappn and capnn bits in the pca0cpmn register are used to select the type of transi- tion that triggers the capture: low-to-high transition (p ositive edge), high-to-low transition (negative edge), or either transition (positive or negative edge). when a capture occurs, the capture/compare flag (ccfn) in pca0cn is set to logic 1 and an interrupt request is generated if ccf interrupts are enabled. the ccfn bit is not automatically cleared by hardware when th e cpu vectors to the interrupt service routine, and must be cleared by software . if both cappn and capnn bi ts are set to logic 1, th en the state of the port pin associated with cexn can be read directly to de termine whether a rising-edge or falling-edge caused the capture. figure 19.4. pca capture mode diagram note: the cexn input signal must remain high or low for at least 2 system clock cycles to be recognized by the hardware. pca0l pca0cpln pca timebase cexn crossbar port i/o pca0h capture pca0cphn 0 1 0 1 (to ccfn) pca interrupt pca0cpmn p w m 1 6 n e c o m n e c c f n t o g n p w m n c a p p n c a p n n m a t n pca0cn c f c r c c f 0 c c f 2 c c f 1
rev. 1.4 199 c8051f52x/f53x 19.2.2. software timer (compare) mode in software timer mode, the pca c ounter/timer value is compared to the module's 16-bit capture/compare register (pca0cphn and pca0cpln). when a match occurs, the capture/compare flag (ccfn) in pca0cn is set to logic 1 and an interrupt request is generated if ccf interrupts are enabled. the ccfn bit is not automatically cleared by hard ware when the cpu vectors to the interrupt service routine, and must be cleared by software. setting the ecomn and matn bits in the pca0cpmn register enables software timer mode. important note about capture/compare registers : when writing a 16-bit value to the pca0 cap- ture/compare registers, the low byte should alwa ys be written first. writing to pca0cpln clears the ecomn bit to 0; writing to pca0cphn sets ecomn to 1. figure 19.5. pca software timer mode diagram match 16-bit comparator pca0h pca0cphn enable pca0l pca timebase pca0cpln 00 00 pca interrupt 0 1 x enb enb 0 1 write to pca0cpln write to pca0cphn reset pca0cpmn p w m 1 6 n e c o m n e c c f n t o g n p w m n c a p p n c a p n n m a t n x pca0cn c f c r c c f 0 c c f 2 c c f 1
c8051f52x/f53x 200 rev. 1.4 19.2.3. high speed output mode in high speed output mode, a module?s associated cexn pin is toggled each time a match occurs between the pca counter and the module's 16- bit capture/compare register (pca0cphn and pca0cpln) setting the togn, matn, and ecomn bits in the pca0cpmn register enables the high- speed output mode. important note about capture/compare registers : when writing a 16-bit value to the pca0 cap- ture/compare registers, the low byte should alwa ys be written first. writing to pca0cpln clears the ecomn bit to 0; writing to pca0cphn sets ecomn to 1. figure 19.6. pca high-speed output mode diagram note: the initial state of the toggle output is logic 1 and is initialized to this state when the module enters high speed output mode. match 16-bit comparator pca0h pca0cphn enable pca0l pca timebase pca0cpln pca interrupt 0 1 00 0x enb enb 0 1 write to pca0cpln write to pca0cphn reset pca0cpmn p w m 1 6 n e c o m n e c c f n t o g n p w m n c a p p n c a p n n m a t n x cexn crossbar port i/o toggle 0 1 togn pca0cn c f c r c c f 0 c c f 2 c c f 1
rev. 1.4 201 c8051f52x/f53x 19.2.4. frequency output mode frequency output mode produces a programmable-freq uency square wave on the module?s associated cexn pin. the capture/compare module high byte holds the number of pca clocks to count before the out- put is toggled. the frequency of the squar e wave is then defined by equation 19.1. equation 19.1. square wave frequency output where f pca is the frequency of the clock selected by the cps2-0 bits in the pca mode register, pca0md. the lower byte of the capture/compare module is co mpared to the pca counter low byte; on a match, cexn is toggled and the offset held in the high byte is added to the matched value in pca0cpln. fre- quency output mode is enabled by setting the ecom n, togn, and pwmn bits in the pca0cpmn register. figure 19.7. pca frequency output mode f cexn f pca 2 pca0 cphn ? ------------------- --------------------- - = note: a value of 0x00 in the pca0cphn register is equal to 256 for this equation. 8-bit comparator pca0l enable pca timebase 000 0 match pca0cpmn p w m 1 6 n e c o m n e c c f n t o g n p w m n c a p p n c a p n n m a t n 0 pca0cphn 8-bit adder pca0cpln adder enable cexn crossbar port i/o toggle 0 1 togn 1
c8051f52x/f53x 202 rev. 1.4 19.2.5. 8-bit pulse width modulator mode each module can be used independently to generate a pulse width modulated (pwm) output on its associ- ated cexn pin. the frequency of the output is depe ndent on the timebase for the pca counter/timer. the duty cycle of the pwm output signal is varied us ing the module's pca0cphn capture/compare register. when the value in the low byte of the pca counter/ti mer (pca0l) is equal to the value in pca0cpln, the output on the cexn pin will be se t. when the count value in pca0l overflows, the cexn output will be reset (see figure 19.8). also, when the counter/ti mer low byte (pca0l) overflows from 0xff to 0x00, pca0cpln is reloaded automatically with the value stored in the module?s capture/compare high byte (pca0cphn) without software intervention. setting t he ecomn and pwmn bits in the pca0cpmn register enables 8-bit pulse width modulator mode. the duty cy cle for 8-bit pwm mode is given by equation 19.2. important note about capture/compare registers : when writing a 16-bit value to the pca0 cap- ture/compare registers, the low byte should alwa ys be written first. writing to pca0cpln clears the ecomn bit to 0; writing to pca0cphn sets ecomn to 1. equation 19.2. 8-bit pwm duty cycle using equation 19.2, the largest duty cycle is 100 % (pca0cphn = 0), and the smallest duty cycle is 0.39% (pca0cphn = 0xff). a 0% duty cycle may be generated by clearing the ecomn bit to 0. figure 19.8. pca 8-bit pwm mode diagram dutycycle 256 pca0 cphn ? ?? 256 ----------------------------------- ---------------- = 8-bit comparator pca0l pca0cpln pca0cphn cexn crossbar port i/o enable overflow pca timebase 0000 0 q q set clr s r match pca0cpmn p w m 1 6 n e c o m n e c c f n t o g n p w m n c a p p n c a p n n m a t n 0
rev. 1.4 203 c8051f52x/f53x 19.2.6. 16-bit pulse width modulator mode a pca module may also be operated in 16-bit pwm mode. in this mode, the 16-bit capture/compare mod- ule defines the number of pca clocks for the low time of the pwm signal. when the pca counter matches the module contents, the output on cexn is asserted high; when the counter over flows, cexn is asserted low. to output a varying duty cycle, new value wr ites should be synchroniz ed with pca ccfn match inter- rupts. 16-bit pwm mode is enabled by setting the ecomn, pwmn, and pwm16n bits in the pca0cpmn register. for a varying duty cycle, match interrupts should be enabled (eccfn = 1 and matn = 1) to help synchronize the capture/co mpare register writes. the duty cycle for 16-bit pwm mode is given by equation 19.3. important note about capture/compare registers : when writing a 16-bit value to the pca0 cap- ture/compare registers, the low byte should alwa ys be written first. writing to pca0cpln clears the ecomn bit to 0; writing to pca0cphn sets ecomn to 1. equation 19.3. 16-bit pwm duty cycle using equation 19.3, the largest duty cycle is 100% (pca0cpn = 0), and the smallest duty cycle is 0.0015% (pca0cpn = 0xffff). a 0% duty cycle may be generated by clearing the ecomn bit to 0. figure 19.9. pca 16-bit pwm mode 19.3. watchdog timer mode a programmable watchdog timer (wdt) function is av ailable through the pca module 2. the wdt is used to generate a reset if the time between writes to th e wdt update register (pca0cph2) exceed a specified limit. the wdt can be configured and enabled/disabled as needed by software. with the wdte bit set in the pca0md register, m odule 2 operates as a watchdog timer (wdt). the module 2 high byte is compared to the pca counter high byte; the module 2 low byte holds the offset to be used when wdt updates are performed. the watchdog timer is enabled on reset. writes to some pca registers are restricted while the watchdog timer is enabled. dutycycle 65536 pca0 cpn ? ?? 65536 ---------------------------------------------------- - = pca0cpln pca0cphn enable pca timebase 0000 0 pca0cpmn p w m 1 6 n e c o m n e c c f n t o g n p w m n c a p p n c a p n n m a t n 1 16-bit comparator cexn crossbar port i/o overflow q q set clr s r match pca0h pca0l
c8051f52x/f53x 204 rev. 1.4 19.3.1. watchdog timer operation while the wdt is enabled: ? pca counter is forced on. ? writes to pca0l and pca0h are not allowed. ? pca clock source bits (cps2-cps0) are frozen. ? pca idle control bit (cidl) is frozen. ? module 2 is forced into software timer mode. ? writes to the module 2 mode register (pca0cpm2) are disabled. while the wdt is enabled, writes to the cr bit will not change the pca counter state; the counter will run until the wdt is disabled. the pca co unter run co ntrol (cr) will read zero if the wdt is enabled but user software has not enabled the pca counter. if a ma tch occurs between pca0cph2 and pca0h while the wdt is enabled, a reset will be gener ated. to prevent a wdt reset, the wdt may be updated with a write of any value to pca0cph2. upon a pca0cph2 write, pca0h plus the offset held in pca0cpl2 is loaded into pca0cph2 (see figure 19.10). figure 19.10. pca module 2 with watchdog timer enabled note that the 8-bit offset held in pca0cph2 is comp ared to the upper byte of the 16-bit pca counter. this offset value is the number of pca0l overflows before a reset. up to 256 pca clocks may pass before the first pca0l overflow occurs, depending on the valu e of the pca0l when the update is performed. the total offset is then given (in pca clocks) by equation 19.4, where pca0l is the value of the pca0l register at the time of the update. equation 19.4. watchdog timer offset in pca clocks the wdt reset is generated when pca0l overflow s while there is a match between pca0cph2 and pca0h. software may force a wdt reset by writing a 1 to the ccf2 flag (pca0cn.2) while the wdt is enabled. pca0h enable pca0l overflow reset pca0cpl2 8-bit adder pca0cph2 adder enable pca0md c i d l w d t e e c f c p s 1 c p s 0 w d l c k c p s 2 match write to pca0cph2 8-bit comparator offset 256 pca0 cpl2 u 256 pca0 l ? + =
rev. 1.4 205 c8051f52x/f53x 19.3.2. watchdog timer usage to configure the wdt, perform the following tasks: ? disable the wdt by writing a 0 to the wdte bit. ? select the desired pca clock s ource (with the cps2-cps0 bits). ? load pca0cpl2 with the desi red wdt update offset value. ? configure the pca idle mode (set cidl if the wd t should be suspended while the cpu is in idle mode). ? enable the wdt by setting the wdte bit to 1. the pca clock source and idle mode select cannot be changed while the wdt is enabled. the watchdog timer is enabled by setting the wdte or wdlck bits in the pca0md register. when wdlck is set, the wdt cannot be disabled until the next system reset. if wdlck is not set, the wdt is disabled by clearing the wdte bit. the wdt is enabled following any rese t. the pca0 counter clock defaults to the system clock divided by 12, pca0l defaults to 0x00, and pca0cpl2 defaults to 0x00. using equation 19.4, this results in a wdt timeout interval of 3072 system clock cycles. table 19. 3 lists some example timeout intervals for typical system clocks. table 19.3. watchdog timer timeout intervals 1 system clock (hz) pca0cpl2 timeout interval (ms) 24,500,000 255 32.1 24,500,000 128 16.2 24,500,000 32 4.1 18,432,000 255 42.7 18,432,000 128 21.5 18,432,000 32 5.5 11,059,200 255 71.1 11,059,200 128 35.8 11,059,200 32 9.2 3,062,500 255 257 3,062,500 128 129.5 3,062,500 32 33.1 191,406 2 255 4109 191,406 2 128 2070 191,406 2 32 530 32,000 255 24576 32,000 128 12384 32,000 32 3168 notes: 1. assumes sysclk / 12 as the pc a clock source, and a pca0l value of 0x00 at the update time. 2. internal oscillator reset frequency.
c8051f52x/f53x 206 rev. 1.4 19.4. register d escriptions for pca following are detailed descriptions of the special func tion registers related to the operation of the pca. sfr definition 19.1. pca0cn: pca control bit7: cf : pca counter/timer overflow flag. set by hardware when the pca counter/timer overflows from 0xffff to 0x0000. when the counter/timer overflow (cf) inte rrupt is enabled, setting this bit causes the cpu to vector to the pca interrupt service routine. this bi t is not automatically cleared by hardware and must be cleared by software. bit6: cr : pca counter/timer run control. this bit enables/disables the pca counter/timer. 0: pca counter/timer disabled. 1: pca counter/timer enabled. bits5?3 : reserved. bit2: ccf2 : pca module 2 capture/compare flag. this bit is set by hardware when a match or capture occurs. when t he ccf2 interrupt is enabled, setting this bit causes the cpu to vect or to the pca interrupt service routine. this bit is not automatically cleared by hard ware and must be cleared by software. bit1: ccf1 : pca module 1 capture/compare flag. this bit is set by hardware when a match or capture occurs. when t he ccf1 interrupt is enabled, setting this bit causes the cpu to vect or to the pca interrupt service routine. this bit is not automatically cleared by hard ware and must be cleared by software. bit0: ccf0 : pca module 0 capture/compare flag. this bit is set by hardware when a match or capture occurs. when t he ccf0 interrupt is enabled, setting this bit causes the cpu to vect or to the pca interrupt service routine. this bit is not automatically cleared by hard ware and must be cleared by software. r/w r/w r/w r/w r/w r/w r/w r/w reset value cf cr reserved reserved reserved ccf2 ccf1 ccf0 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit addressable sfr address: 0xd8
rev. 1.4 207 c8051f52x/f53x sfr definition 19.2 . pca0md: pca mode bit7: cidl : pca counter/timer idle control. specifies pca behavior when cpu is in idle mode. 0: pca continues to function normally while the system controller is in idle mode. 1: pca operation is suspended while the system controller is in idle mode. bit6: wdte : watchdog timer enable if this bit is set, pca module 2 is used as the watchdog timer. 0: watchdog timer disabled. 1: pca module 2 enabled as watchdog timer. bit5: wdlck : watchdog timer lock this bit locks/unlocks the watchdog timer en able. when wdlck is set, the watchdog timer may not be disabled until the next system reset. 0: watchdog timer enable unlocked. 1: watchdog timer enable locked. bit4: unused . read = 0b, write = don't care. bits3?1 : cps2?cps0 : pca counter/time r pulse select. these bits select the timebase source for the pca counter . bit0: ecf : pca counter/timer over flow interrupt enable. this bit sets the masking of the pca co unter/timer overflow (cf) interrupt. 0: disable the cf interrupt. 1: enable a pca counter/timer overflow interrupt request when cf (pca0cn.7) is set. note: when the wdte bit is set to 1, the pca0md register cannot be modified. to change the contents of the pca0md register, the watchdog timer must first be disabled. r/w r/w r/w r r/w r/w r/w r/w reset value cidl wdte wdlck - cps2 cps1 cps0 ecf 01000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: 0xd9 cps2 cps1 cps0 timebase 0 0 0 system clock divided by 12 0 0 1 system clock divided by 4 0 1 0 timer 0 overflow 0 1 1 high-to-low transitions on eci (max rate = system clock divided by 4) 1 0 0 system clock 1 0 1 external clock divided by 8 * 1 1 0 reserved 1 1 1 reserved note: external clock divided by 8 is synchronized with the system clock.
c8051f52x/f53x 208 rev. 1.4 sfr definition 19.3. pca0cpmn : pca capture/compare mode bit7: pwm16n : 16-bit pulse width modulation enable. this bit selects 16-bit mode when pulse width modulation mode is enabled (pwmn = 1). 0: 8-bit pwm selected. 1: 16-bit pwm selected. bit6: ecomn : comparator function enable. this bit enables/disables the comp arator function for pca module n. 0: disabled. 1: enabled. bit5: cappn : capture positive function enable. this bit enables/disables the positive edge capture for pca module n. 0: disabled. 1: enabled. bit4: capnn : capture negative function enable. this bit enables/disables the negative edge capture for pca module n. 0: disabled. 1: enabled. bit3: matn : match function enable. this bit enables/disables the match function for pca module n. when enabled, matches of the pca counter with a module's capture/comp are register cause the ccfn bit in pca0md register to be set to logic 1. 0: disabled. 1: enabled. bit2: togn : toggle function enable. this bit enables/disables the toggle function for pca module n. when enabled, matches of the pca counter with a module's capture/comp are register cause the logic level on the cexn pin to toggle. if the pwmn bit is also set to logic 1, the module operates in frequency output mode. 0: disabled. 1: enabled. bit1: pwmn : pulse width modulation mode enable. this bit enables/disables the pwm function for pca module n. when enabled, a pulse width modulated signal is output on the cexn pin. 8-bi t pwm is used if pwm16n is cleared; 16-bit mode is used if pwm16n is set to logic 1. if the togn bit is also set, the module operates in frequency output mode. 0: disabled. 1: enabled. bit0: eccfn : capture/compare flag interrupt enable. this bit sets the masking of the capture/compare flag (ccfn) interrupt. 0: disable ccfn interrupts. 1: enable a capture/compare flag interrupt request when ccfn is set. r/w r/w r/w r/w r/w r/w r/w r/w reset value pwm16n ecomn cappn capnn matn togn pwmn eccfn 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: pca0cpm0: 0xda, pca0cpm1: 0xdb, pca0cpm2: 0xdc
rev. 1.4 209 c8051f52x/f53x sfr definition 19.4. pca0l: pca counter/timer low byte sfr definition 19.5. pca0h: pca counter/timer high byte sfr definition 19.6. pca0cpln: pca capture module low byte sfr definition 19.7. pca0cphn: pca capture module high byte bits7?0 : pca0l : pca counter/timer low byte. the pca0l register holds the low byte (lsb) of the 16-bit pca counter/timer. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: 0xf9 bits7?0 : pca0h : pca counter/timer high byte. the pca0h register holds the high byte (msb) of the 16-bit pca counter/timer. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr address: 0xfa bits7?0 : pca0cpln : pca capture module low byte. the pca0cpln register holds the low byte (lsb) of the 16-bit capture module n. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: pca0cpl0: 0xfb, pca0cpl1: 0xe9, pca0cpl2: 0xeb bits7?0 : pca0cphn : pca capture module high byte. the pca0cphn register holds the high byte (msb) of the 16-bit capture module n. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: pca0cph0: 0xfc, pca0cph1: 0xe9, pca0cph2: 0xec
c8051f52x/f53x 210 rev. 1.4 20. device specific behavior this chapter contains behavioral differences between the silicon revi sions of c8051f52x/52xa/f53x/53xa devices. these differences do not affect the functionality or performance of most systems and are described below. 20.1. device identification the part number identifier on the top side of the device package can be used for decoding device information. the first charac ter of the trace code identifies the silicon revision. on c8051f52x-c/53x-c devices, the trace code (second line on the tssop-20 and dfn-10 packages; third line on the qfn-20 package) will begin with the letter "c". the "a" suffix at the end of the part number such as "c8051f530a" is only present on revision b devices. all other revisions do not include this suffix. figures 20.1 , 20.2 , and 20.3 show how to find the part number on the top side of the device package. figure 20.1. device package?tssop 20 figure 20.2. device package?qfn 20 first character of the trace code identifies the silicon revision first character of the trace code identifies the silicon revision
rev. 1.4 211 c8051f52x/f53x figure 20.3. device package?dfn 10 20.2. reset pin behavior the reset behavior differs between the silicon revisions of c8051f52x/ 52xa/f53x/f53xa devices. the dif- ferences affect the state of the rst pin during a vdd monitor reset. on revision a devices, a v dd monitor reset does not af fect the state of the rst pin. on revision b and revision c devices, a v dd monitor reset will pull the rst pin low for the duration of the brownout condi- tion. 20.3. reset time delay the reset time delay differs be tween the silicon revisions of c8 051f52x/52xa/f53x/f53xa devices. on revision a devices, the reset time delay will be as long as 80 ms following a power-on reset, meaning it can take up to 80 ms to begin code execution. subs equent resets will not cause the long delay. on revi- sion b and revision c devices, the startu p time is around 350 s, specified as t pordelay in table 2.8, ?reset electrical characteristics,? on page 32. 20.4. v dd monitors and v dd ramp time the number of v dd monitors and definition of ?v dd ramp time? differs betwe en the silicon revisions of c8051f52x/52xa/f53x/f53xa devices. on revision a and revision b devices, the only v dd monitor present is the standard v dd monitor (vddmon0). on these devices, the v dd ramp time is defined as how fast v dd ramps from 0 v to v rst . here, v rst is the v rst-low threshold of vddmon0 specifed in tabl e 2.8, ?reset elec trical characteris- tics,? on page 32. the maximum v dd ramp time for these devices is 1 ms; slower ramp times may cause the device to be released from reset before v dd reaches the v rst-low level. revision c devices include two v dd monitors: a standard v dd monitor (vddmon0) and a level-sensitive v dd monitor (vddmon1). see section 11.2 on page 108 for more details. on these devices, the v dd ramp time is defined as how fast v dd ramps from 0 v to v rst1 . v rst1 is specified in table 2.8, ?reset electrical characteristics,? on page 32 as the threshold of the new level-sensitive v dd monitor (vddmon1). this new v dd monitor will hold the device in reset until v dd reaches the v rst1 level irre- spective of the length of the v dd ramp time. note: please refer to section ?11.2.1. vdd monitor thresholds and minimum vdd? on page 108 for recommendations related to minimum v dd . ? first character of the trace code identifies the silicon revision
c8051f52x/f53x 212 rev. 1.4 20.5. v dd monitor (vddmon0) high threshold setting the calibration behavior of the internal voltage regulator (reg0) and its impact on v dd monitor (vddmon0) high threshold setting differs between the silicon revisions of c8051f52x/52x a/f53x/f53xa devices. the following note applies to revision a and revision b devices : the output of the internal voltage reg- ulator (reg0) is calibrated by the mcu immediately after any reset event. the output of the un-calibrated internal regulator could be below the high threshold setting (v rst-high ) of the v dd monitor (vddmon0). if this is the case and the v dd monitor is set to the high threshold setting and if the mcu receives a non- power on reset, th e mcu will remain in reset until a po wer-on reset (por) occurs (i.e. v dd monitor will keep the device in reset). a por will force the v dd monitor to the low threshold setting which is guaran- teed to be below the un-c alibrated output of the internal regulator. the de vice will then exit reset and resume normal operation. it is for this reason silicon labs strongly reco mmends that the v dd monitor is always left in the low threshold setting (i.e., default value upon por). when programming the flash in-system, the v dd monitor (vddmon0) must be set to the high threshold setting. for the highest system reliability, the time the v dd monitor is set to the high threshold setting should be minimized (e.g., setting the v dd monitor to the high threshold setting just before the flash write operation and then changing it back to the low threshold setting immediately after the flash write opera- tion). the following note applies to revision c devices : the output of the internal voltage regulator (reg0) is calibrated by the mcu immediately after a power-on reset (por). this calibrated output setting will stay calibrated through any type of reset other than por. beca use of this change in behavior of reg0, the ?low threshold? recommendation noted above for revision a and revision b devices does not apply to revision c devices; the v dd monitor (vddmon0) can be set to the hi gh threshold as needed depending on the application. 20.6. reset low time the maximum reset low time differs between the silicon revisions of c8051f52x/52xa/f53x/f53xa devices. reset low time is the duration for which the rst pin is driven low by an external circuit while power is applied to the device. on revision a and revision b devices with assembly build date code earlier than 1124 (year 2011, work week 24), the reset low time should be a maximum of 1 second. for longer reset low times, a percentage of device s within a narrow range of temperatures (a 5 to 10 c window) may ?lock up? and fail to execute code. the cond ition is cleared only by cycling power. revision b devices with assembly date code 1124 or later and revision c devices do not have any restric- tions on reset low time. 20.7. internal oscillator suspend mode the required bias setting for the internal oscillator before entering suspend mo de differs between the sili- con revisions of c8051f52x/52xa/f53x/f53xa devices. on revision a and revision b devices, firmware must set the ztcen bit in ref0cn (sfr definition 5.1) before entering suspend mode. if zt cen is not set to 1, there is a lo w probability of the device remaining in suspend even when a wake-up condition is triggered. on revision c devices, this bit need not be set to 1 before entering suspend mode.
rev. 1.4 213 c8051f52x/f53x 20.8. uart pins the location of the pins used by the serial uart interface differs between the silicon revisions of c8051f52x/52xa/f53x/f53xa devices. on revision a devices, the tx and rx pins used by the uart interface are mapped to the p0.3 (tx) and p0.4 (rx) pins. beginning with revision b devices, the tx and rx pins used by the uart interface are mapped to the p0.4 (tx) and p0.5 (rx) pins. important note: on revision b and newer devices, the uart pins must be skipped if the uart is enabled in order for peripherals to appear on port pins beyond the uart on the crossbar. for example, with the spi and uart enabled on the crossbar wit h the spi on p1.0-p1.3, the uart pins must be skipped using p0skip for the spi pins to appear correctly. 20.9. lin the lin peripheral behavior differs between the silicon revisions of c8051f52x/52xa/f53x /f53xa devices. the differences are: 20.9.1. stop bit check on revision a devices, the stop bits of the fields in the lin frame are not checked and no error is gener- ated if the stop bits could not be sent or received co rrectly. on revision b and revision c devices, the stop bits are checked, and an error will be generated if the st op bit was not sent or received correctly. 20.9.2. synch break and synch field length check on revision a devices, the check of sync field length versus sync break length is incorrect. on revision b and revision c devices, the sync break length must be larger than 10 bit times (of the measured bit time) to enable the synchronization.
c8051f52x/f53x 214 rev. 1.4 21. c2 interface c8051f52x/f52xa/f53x/f53xa devices include an on-chip silicon lab oratories 2-wire (c2) debug inter- face to allow flash programming and in-system debugg ing with the production part installed in the end application. the c2 interface uses a clock signal (c2ck) and a bi-directional c2 data signal (c2d) to trans- fer information between the device and a host system. see the c2 interface specification for details on the c2 protocol. 21.1. c2 interface registers the following describes the c2 registers necessary to perform flash programming functions through the c2 interface. all c2 registers are accessed through the c2 interface as described in the c2 interface spec- ification. c2 register definition 21.1. c2add: c2 address c2 register definition 21. 2. deviceid: c2 device id bits7?0 : the c2add register is accessed via the c2 interface to select the target data register for c2 data read and data write commands. reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 address description 0x00 selects the device id register for data read instructions (deviceid) 0x01 selects the revision id register for data read instructions (revid) 0x02 selects the c2 flash programming control register for data re ad/write instructions (fpctl) 0xb4 selects the c2 flash programming data register for data read/write instructions (fpdat) this read-only register returns the 8-bit device id: 0x11 (c8051f52x/f52xa/f53x/f53xa). reset value 00010001 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
rev. 1.4 215 c8051f52x/f53x c2 register definition 21. 3. revid: c2 revision id c2 register definition 21.4. fpct l: c2 flash programming control c2 register definition 21.5. fp dat: c2 flash programming data this read-only register returns the 8-bit revision id. ? for example, 0x00 = revision a. reset value varies bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bits7?0 fpctl : flash programming control register. this register is used to enable flash programmi ng via the c2 interface. to enable c2 flash programming, the following codes must be writte n in order: 0x02, 0x01. note that once c2 flash programming is enabled, a system reset mu st be issued to resume normal operation. reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bits7?0 : fpdat : c2 flash programming data register. this register is used to pass flash comma nds, addresses, and data during c2 flash accesses. valid commands are listed below. reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 code command 0x06 flash block read 0x07 flash block write 0x08 flash page erase 0x03 device erase
c8051f52x/f53x 216 rev. 1.4 21.2. c2 pin sharing the c2 protocol allows the c2 pins to be shared wi th user functions so that in-system debugging and flash programming functions may be performed. this is possible because c2 co mmunication is typically performed when the device is in the halt state, where all on-chip peripherals and user software are stalled. in this halted state, the c2 interface can safely ?b orrow? the c2ck (/rst) and c2 d (p0.1 or p0.6) pins. in most applications, external resistors are required to is olate c2 interface traffic from the user application. a typical isolation configuratio n is shown in figure 21.1. figure 21.1. typical c2 pin sharing the configuration in figure 21.1 assumes the following: 1. the user input (b) cannot change stat e while the target device is halted. 2. the /rst pin on the target device is used as an input only. additional resistors may be necessary depending on the specific application. c2d c2ck /reset (a) input (b) output (c) c2 interface master c8051fxxx
rev. 1.4 217 c8051f52x/f53x d ocument c hange l ist revision 0.3 to 0.4 ? updated all specification tables. ? added 'f52xa and 'f53xa information. ? updated the selectab le gain section in the adc section. ? updated the external crystal exam ple in the oscillators section. ? updated the lin section. revision 0.4 to 0.5 ? updated all specification tables. ? updated figures 1.1, 1.2, 1.3, and 1.4. ? updated section 4 pinout diagrams and tables. revision 0.5 to 1.0 ? updated all specification tables and moved them to one section. ? added figure 3.1 and figure 3.2. ? updated section 4 pinout diagrams and tables. ? updated figure 5.6. ? added figure 15.3. ? updated equations in section 17. ? updated figure 21.3. revision 1.0 to 1.1 ? updated table 2.3, ?adc0 electrical characteri stics,? on page 28 with new burst mode oscillator specification, new power supply current maximum, and made corrections to temperature sensor offset and offset error conditions. ? updated table 2.9, ?flash electrical characteri stics,? on page 33 with ne w flash write and erase timing. ? made correction in equivalent gain table in section ?4.4. selectable gain? on page 60. ? updated section ?11.2. power-fa il reset / vdd monitors (vddmon0 and vddmon1)? on page 108 regarding higher v dd monitor threshold. revision 1.1 to 1.2 ? updated ?ordering information? on page 14 and table 1.1, ?product selection guide (recommended for new designs),? on page 14 to include -a (a utomotive) devices and automotive qualification information. ? updated table 2.3, ?adc0 electrical characterist ics,? on page 28 to include temperature sensor tracking time requirement and update inl maximum specification. ? updated figure 3.2. ?dfn-10 package diagram? on page 38 with new pin-1 detail drawing. ? updated table 8.1, ?cip-51 instru ction set summary,? on page 83 with correct cjne and cpl timing. ? updated ?power-fail reset / vdd monitors (vddmo n0 and vddmon1)? on page 108 to clarify the recommendations for the vdd monitor. note: all items from the c8051f52xa-f53xa errata dated august 26, 2009 are incorporated into this data sheet.
c8051f52x/f53x 218 rev. 1.4 revision 1.2 to 1.3 ? updated ?system overview? on page 13 with a volta ge range specification for the internal oscillator. ? updated table 2.11 on page 34 with new conditions fo r the internal oscillator accuracy. the internal oscillator accuracy is dependent on the operating voltage range. ? updated section 2 to remove the internal oscillator curve across temp erature diagram. ? updated figure ?4.5 12-bit adc burst mode example with repeat count set to 4? on page 58 with new timing diagram when using cnvstr pin. ? updated sfr definition 5.1 (ref0cn) with oscillator suspend requirement for ztcen. ? updated sfr definition 6.1 (reg0cn) with a new definition for bit 6. the bit 6 reset value is 1b and must be written to 1b. ? updated section ?8.3.3. suspend mode? on page 90 with note regarding ztcen. ? updated section ?17. lin (c8051f520/0a/3/3a/6/6 a and c8051f530/0a/3/3a/6/6a)? on page 164 with a voltage range specification for the inter nal oscillator. revision 1.3 to 1.4 ? added ?aec-q100? qualification information on page 1. ? changed page headers throughout the document from ?c8051f52x/f52xa/f53x/f53xa? to ?c8051f52x/53x?. ? updated supply voltage to "2.0 to 5.25 v" on page 1 and in section 1 on page 13. ? corrected reference to development kit (c8051f530dk ) in section ?1.2.4. on-chip debug circuitry? on page 18. ? updated minimum supply input voltage (v regin ) for c8051f52x-c/f53x-c devices in table 2.2 on page 26 and table 2.6 on page 30. ? updated digital supply current (i dd and idle i dd ) typical values for condit ion ?clock = 25 mhz? in table 2.2 on page 26. ? updated i dd frequency sensitivity and idle i dd frequency sensitivity values in table 2.2 on page 26; removed figure 2.1 and figure 2.2 that used to pr ovide the same frequency sensitivity slopes. also removed idd supply sensitivity and idle idd supply sensitivity typical values. ? added digital supply current (stop or suspend mode ) values at multiple temperatures table 2.2 on page 26. ? added a note in table 2.3, ?adc0 electrical characteristics,? on page 28 with reference to section ?4.4. selectable gain? on page 60 ; also added note to indicate that additional tracking time may be necessary if vdd is less th an the minimum specified vdd. ? split off temperature sensor specifications from ta ble 2.3 into a separate table table 2.4; updated temperature sensor gain and added supply current values. ? added temperature condition for bias curren t specification in table 2.6 on page 30. ? updated comparator input offset vo ltage values in table 2.7 on page 31. ? updated vdd monitor (vdd mon0) low threshold (v rst-low ) minimum value for c8051f52xa/f52x- c/f53xa/f53x-c devices in table 2.8 on page 32. ? updated vdd monitor (vddmon0) supply current values in table 2.8 on page 32. ? added specifications for the new level-sensitive vdd monitor (v ddmon1) to table 2.8, ?reset electrical characteristics,? on page 32 and also added notes to clarify the applicable v rst theshold level. ? added note in table 2.9, ?flash electrical characteristics,? on page 33 to describe the minimum flash programming temperature for ?i (industrial grade) de vices; also added the sa me note and references to it in section ?12.1. programming the flash memo ry? on page 113, section ?12.3. non-volatile data storage? on page 117, and in sfr definition 12.1 (psctl).
rev. 1.4 219 c8051f52x/f53x ? replaced minimum vdd value for flas h write/erase operations in table 2.9 on page 33 with references to the v rst-high theshold specified in table 2.8 on page 32. ? removed output low voltage values for condition ?v regin = 1.8 v? from table 2.10, ?port i/o dc electrical characteristics,? on page 33. ? corrected minor typo (?ifcn = 111b?) in table 2.11, ?internal oscillato r electrical characteristics,? on page 34. ? removed the typical value and added the maximum value for the 'wake-up time from suspend' specification with the 'ztcen = 0' condition in table 2.11, ?internal oscillator el ectrical characteristics,? on page 34. ? added internal oscillator supply current values at sp ecific temperatures for conditions ?ztcen = 1? and ?ztcen = 0? in table 2.11, ?internal oscillator electrical ch aracteristics,? on page 34. also updated the table name to clarify that the specifications apply to the internal oscillator. ? updated section ?1.1. ordering information? on page 14 and table 1.1 with new c8051f52x-c/f53x-c part numbers. ? updated table 1.2, ?product selection guide (not recommended for new designs),? on page 15 to include c8051f52xa/f53xa part numbers. ? updated figure 1.1, figure 1.2, figure 1.3, and figure 1.4 titles to clarify applicable silicon revisions. ? added figure references to pinout diagrams (figure 3. 1, figure 3.4, and figure 3.7) and updated labels to clarify applicable part numbers. ? updated table 3.1, table 3.4, and table 3.7 to indicate pinouts applicable to c8051f52x-c/f53x-c devices. ? added note in section ?6. voltage regulator (reg0)? on page 74 to indicate the need for bypass capacitors for voltage regulator stability. ? updated figure 11.1 on page 106 and text in sect ion ?11.1. power-on reset? on page 107 and section ?11.2. power-fail reset / vdd monitors (vddmon0 and vddmon1)? on page 108 to describe the new level-sensitive v dd monitor (vddmon1). ? updated sfr definition 11.1. ?vddmon: vdd monito r control? on page 109 to include the vdm1en bit (bit 4) that controls the new level-sensitive v dd monitor (vddmon1). ? added notes in section 11.1 on page 107, section 11.2 on page 108, and section 11.3 on page 110 with references to relevant parts of section ?20. device specific behavior? on page 210. ? moved some notes related to vdd monitor (vddmon0) high threshold setting (v rst-high ) from section 11.2 on page 108 to section 20.5 on page 212 in section ?20. device specific behavior?. ? added section ?11.2.1. vdd monitor thresholds and minimum vdd? on page 108 to describe the recommendations for minimum v dd as it relates to the v dd monitor thresholds. ? clarified text in section ?11.7. flash error reset? on page 110. ? clarified text in items 2, 3 and 4 in section ?12.2.1. v dd maintenance and the v dd monitor? on page 115 to reference appropriate specificat ion tables and specify ?vddmon0?.
c8051f52x/f53x 220 rev. 1.4 c ontact i nformation silicon laboratories inc. 400 west cesar chavez ? austin, tx 78701 ? tel: 1+(512) 416-8500 ? fax: 1+(512) 416-9669 ? toll free: 1+(877) 444-3032 please visit the silicon labs technical support web page: ? https://www.silabs.com/support/pages/contacttechnicalsupport.aspx ? and register to submit a technical support request. silicon laboratories and silicon labs are trademarks of silicon laboratories inc. other products or brandnames mentioned herein are trademarks or registered trademarks of their respective holders. the information in this document is believed to be accurate in al l respects at the time of publ ication but is subject to change without notice. silicon laboratories assumes no re sponsibility for errors and omissions, and disclaims responsibi lity for any consequen ces resulting from the use of information included herein. additi onally, silicon laborator ies assumes no responsibility for the fun ction- ing of undescribed features or parameters. silicon laboratories reserves the right to make change s without further notice. sili con laboratories makes no warranty, representation or guarantee regarding the suitability of its products for any particular purpos e, nor does silicon laboratories assume any liabi lity arising out of the application or use of any product or circuit, and specifi cally disclaims any and all liability, including without limitation consequential or incident al damages. silicon laboratories product s are not designed, intended, or authorized for use in applications in tended to support or sustain life, or for any other application in which the failure of the silicon laboratories product could create a si tuation where personal injury or death may occur. should buyer purchase or use silicon laboratories prod ucts for any such unintended or unauthorized application, buyer shall indemnify and hold silicon laboratories harmless against all claims and damages.
mouser electronics authorized distributor click to view pricing, inventory, delivery & lifecycle information: silicon laboratories: ? toolstick530adc? toolstick520pp? toolstick530tpp? toolstick530mpp


▲Up To Search▲   

 
Price & Availability of C8051F536-C-IT

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X